【问题标题】:Choose Android.R.layout when setup GridView in android在android中设置GridView时选择Android.R.layout
【发布时间】:2015-02-04 16:24:00
【问题描述】:

我目前正在研究网格视图。

由于网格视图项只是一个文本视图,我没有创建自定义布局。

但是当我尝试使用simple_list_item_1时,我发现item点击区域只是文本的大小,而不是整个item。

所以我改成simple_list_item_single_choice,点击区域是整个item但是文字不在view的中心

因此,我想知道我应该为布局选择什么? 1.视图中的文本中心 2. 可点击整个项目,而不仅仅是文本视图

感谢您的帮助。

【问题讨论】:

  • 为什么不创建自定义布局?
  • 那是因为我只需要一个文本视图,如果所有默认布局都不合适,这是最后的手段
  • 您知道使用自定义布局所花费的时间比您使用搜索正确布局或写问题所花费的时间少吗?如果您是初学者并且需要帮助来获得正确的布局,请说出来。
  • 感谢您的帮助。如果有推荐的布局就好了。如果没有的话。然后我将通过自定义布局来完成它

标签: android android-layout android-gridview android-adapter


【解决方案1】:

将此用作布局! ;D

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:gravity="center"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:minHeight="?android:attr/listPreferredItemHeightSmall" />

这些是区别..

    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多