GravityプロパティをXMLアイテムに適用した後、正しい場所に配置されていないようです。どのようにこれらの問題を固定することができるので、以下の条件が満たされているか?:LinearLayoutアイテムに重大な重力が適用されました
「上に移動」ボタンを- 画面の縦中心 activity_main.xml
にする画面
GridView
ニーズの底3210 UPDATE(akshay_shahaneの提案)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:orientation="vertical"
android:weightSum="100"
tools:context=".MainActivity">
<Button
android:id="@+id/btn_moveup"
android:text="move up"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="5"
android:onClick="moveup_click"
/>
<GridView
android:id="@+id/abslistview_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="90"
android:layout_gravity="center_vertical"
android:numColumns="auto_fit"
/>
<Button
android:id="@+id/btn_movedown"
android:text="move down"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_weight="5"
android:onClick="movedown_click"
/>
</LinearLayout>
にGridViewの重みを設定する必要があります試してみてください? 0.1、グリッド0.8を上に移動し、0.1に移動するために –
@akshay_shahane私はしましたが、GridViewの重力は引き続きプレイしています!それは垂直の中心に行くことはありません! – MacaronLover
ルートレイアウトの重力をcenterVerticalに設定しようとしましたか? –