【发布时间】:2014-04-13 03:43:56
【问题描述】:
我正在开发一个使用自定义列表视图的应用程序。 XML 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/loginbg" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="15sp"
android:background="@android:color/white" >
<ListView
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#000000"
android:dividerHeight=".5sp" >
</ListView>
</RelativeLayout>
</RelativeLayout>
我的自定义适配器 XML 是:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="75sp"
android:paddingBottom="75sp"
android:gravity="center"
android:textSize="20sp"
android:textColor="@android:color/white" />
</RelativeLayout>
但我的输出并不像我需要的那样。我需要在 XML 适配器 textview 中给出的文本垂直填充。
我的输出是:
我需要列表视图适配器中文本视图中顶部和底部文本的空间。
我也尝试从 .java 文件:
textView.setPadding(0, 75, 0, 75);
但没用。
我需要这样的输出:
请指导我现在该怎么做。
【问题讨论】:
-
对于填充使用
dp单位而不是sp(应该只用于字体大小) -
好的,但我该怎么办。我现在用 dp。
-
@ManojFegde 使用了 dp,但您没有得到想要的结果?
-
不,我没有得到结果。
标签: android android-layout listview android-listview android-adapter