【发布时间】:2016-05-16 17:02:25
【问题描述】:
我正在尝试制作这样的列表视图: Listview I want
我尝试了以下方法:
-
通过在列表视图中设置它但它不起作用
android:divider="@android:color/transparent" android:dividerHeight="10.0sp" 通过在 textview 布局中设置
marginTop但它也不起作用。
所以有人可以帮助我如何获得所需的输出。
这是我的自定义列表视图:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/activity_vertical_margin"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:layout_width="8dp"
android:layout_height="wrap_content"/>
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:id="@+id/imageView"
android:layout_margin="5dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView"
android:layout_margin="5dp"
style="@style/AppTheme.Text"
/>
<View
android:layout_width="8dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#fff"/>
</LinearLayout>
我得到了这个:
【问题讨论】:
-
您能否发布有关您的 ListView 的更多详细信息?它有自定义视图(xml 文件)吗?
-
我已经更新了@RosárioPereiraFernandes 的问题
-
不要将 SP 与这些属性一起使用。它用于字体大小。更多信息请查看 - stackoverflow.com/questions/2025282/…
-
我试过那个,但我主要使用 dp
-
恕我直言,您应该使用
RecyclerView with CardView而不是 OLDListView。那只会给你YOUR DESIRED LISTVIEW。
标签: android android-layout listview