Android ListView项目离开屏幕
问题是,当我运行程序时,视图会像上图所示那样剪切 我不知道到底是什么样的问题,所以如果你需要什么东西来展示,尽管问吧 顺便说一下,我正在使用kotlin 编辑1: result_row.xml这是ListView中显示的行的xmlAndroid ListView项目离开屏幕,android,xml,android-studio,listview,kotlin,Android,Xml,Android Studio,Listview,Kotlin,问题是,当我运行程序时,视图会像上图所示那样剪切 我不知道到底是什么样的问题,所以如果你需要什么东西来展示,尽管问吧 顺便说一下,我正在使用kotlin 编辑1: result_row.xml这是ListView中显示的行的xml <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app=
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/itemName"
android:layout_width="200dp"
android:layout_height="40dp"
android:gravity="center"
android:text="Name"
android:textColor="#000000"
android:textSize="16sp" />
<View
android:id="@+id/lineView2"
android:layout_width="2dp"
android:layout_height="40dp"
android:background="#010101" />
<TextView
android:id="@+id/itemWeight"
android:layout_width="100dp"
android:layout_height="40dp"
android:gravity="center"
android:text="Item Weight"
android:textColor="#000000"
android:textSize="16sp" />
<View
android:id="@+id/lineView1"
android:layout_width="2dp"
android:layout_height="40dp"
android:background="#010101" />
<TextView
android:id="@+id/itemPrice"
android:layout_width="100dp"
android:layout_height="40dp"
android:gravity="center"
android:text="Price"
android:textColor="#000000"
android:textSize="16sp" />
</LinearLayout>
</FrameLayout>
在布局xml文件中编辑
layout_width="0dp"
layoyt_height="0dp"
您的
TextView
s具有固定宽度,总宽度大于屏幕宽度:
android:layout_width="200dp"
...
android:layout_width="100dp"
...
android:layout_width="100dp"
Android手机可以窄到320dp,所以会被切断。您需要修改布局以使用可用空间,而不是硬编码固定宽度。或者,如果你真的想使用固定宽度,它们需要更小(加起来不应该超过
320dp
)。不要使用固定宽度高度你能分享你的结果吗?“你能分享你的结果吗?\u row.xml?”当然“不要使用固定宽度高度”我试过了,但还是有一部分偏离了,有些文字从屏幕上消失了,我现在就试试看,看看发生了什么。尽管屏幕上出现了垃圾,但至少比以前好多了。。。我会把它标为thx