0
我没有Listview的重力选项,最接近前景引力,但这也不起作用。我如何让列表视图从箭头所在的左上角开始,而不是从中间开始?列表视图从中心开始而不是左上角
content_xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.myname.appname.MainActivity"
tools:showIn="@layout/activity_main">
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textFilterEnabled="false"
android:foregroundGravity="top|left" />
</RelativeLayout>
更改ListView的'layout_width'和'layout_height'到'match_parent'。您也可以删除'layout_center *'属性。 –
@MikeM。作品。谢谢。 – kar
删除android:layout_centerVertical =“true”并将layout_width和layout_height更改为match_parent – user320676