Listview从中心而不是左上角开始

时间:2015-12-08 14:40:39

标签: android xml

我没有Listview的重力选项,最接近的是前景引力,但这也不起作用。如何使列表视图从箭头所在的左上角开始,而不是从中间开始?

enter image description here

.find()

1 个答案:

答案 0 :(得分:1)

将列表视图layout_widthlayout_height设为match_parent,这样可以解决问题。下面的代码应该适合你。

<?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="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/listView"  
    android:textFilterEnabled="false" />

相关问题