ListView TextView Items每个条目之间有很大的差距
我很难将文本视图直接排列在彼此下方。我面临的问题是将我的第二个 TextView“prodlocation”排列在“prodname”下面。我这两个项目之间有很大差距。我尝试过“layout_gravity =“top””,但差距仍然存在。有更好的方法来实现这一点吗?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/myselector">
<com.github.droidfu.widgets.WebImageView
android:id="@+id/productimg"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:id="@+id/prodname"
android:textColor="@drawable/selected_text"
android:textStyle="bold"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
/>
<TextView
android:id="@+id/prodlocation"
android:textColor="@drawable/selected_text"
android:layout_gravity="top"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:singleLine="true"
/>
<TextView
android:id="@+id/prodorigin"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:singleLine="true"
/>
<TextView
android:id="@+id/savings"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:singleLine="true"
/>
<TextView
android:id="@+id/price"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:singleLine="true"
/>
</LinearLayout>
<ImageView
android:id="@+id/throbber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_popup_sync_1"
android:visibility="gone"
/>
</LinearLayout>
I'm having a difficult time lining up my text views directly underneath each other. The problem I'm facing is lining up my second TextView "prodlocation" underneath "prodname". I have a big gap between the two items. Ive tried "layout_gravity="top"" but the gap is still there. Is there a better way to accomplish this?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/myselector">
<com.github.droidfu.widgets.WebImageView
android:id="@+id/productimg"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="fill_parent">
<TextView
android:id="@+id/prodname"
android:textColor="@drawable/selected_text"
android:textStyle="bold"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
/>
<TextView
android:id="@+id/prodlocation"
android:textColor="@drawable/selected_text"
android:layout_gravity="top"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:singleLine="true"
/>
<TextView
android:id="@+id/prodorigin"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:singleLine="true"
/>
<TextView
android:id="@+id/savings"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="2"
android:singleLine="true"
/>
<TextView
android:id="@+id/price"
android:textColor="@drawable/selected_text"
android:paddingLeft="10dip"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="3"
android:singleLine="true"
/>
</LinearLayout>
<ImageView
android:id="@+id/throbber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_popup_sync_1"
android:visibility="gone"
/>
</LinearLayout>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试删除您的 prodName
TextView
的layout_weight =“1”。Try to remove the layout_weight="1" of your prodName
TextView
.