【问题标题】:String types not allowed (at 'gravity' with value 'end')不允许使用字符串类型(在 'gravity' 处,值为 'end')
【发布时间】:2012-01-04 11:11:31
【问题描述】:

我想将图像放在我的列表中的最右边,并按照 http://developer.android.com/reference/android/widget/LinearLayout.html#attr_android:gravity 我正在努力做

    <ImageView
    android:id="@+id/list_now_playing"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="end"
    >
</ImageView>

但我遇到了错误。 请提出解决方案

【问题讨论】:

  • 您使用的是哪个 Android 版本?
  • 为您的文本视图使用 fill_parent 或 layout_weight=1

标签: android list listview imageview


【解决方案1】:

该属性值end 在不低于该值的 Android 4.0 (ICS) 中可用。

第二件事是,您可能需要将 ImageView 的高度/宽度设置为 fill_parent

编辑

然后另一种将其移动到极右端的方法将 RelativeLayout 作为 row 的父级并在 ImageView 中设置 android:layout_alignParentRight="true"android:layout_centerVertical="true"

【讨论】:

  • 是的科学怪人,你是对的,这个属性在 Android 4.0 中工作
  • 我做了这个 android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="right" 图像向右移动但不是在最后..
  • @shankey 然后将其移动到极右端,将 RelativeLayout 作为 row 的父级并在 ImageView 中设置 android:layout_alignParentRight="true"android:layout_centerVertical="true"
  • @Frankenstein:先生,我做到了,但静止图像没有移动到极右。它被放置在中间。
猜你喜欢
  • 2016-05-01
  • 1970-01-01
  • 2017-04-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多