最初の子をLinearLayout
の高さをmatch_parent
に設定すると、画面のサイズに高さが吹きます。なぜこれが起こっているのか分かりません。親はRelativeLayout
なので、最初の子の高さをとし、その高さがmatch_parent
に設定されている場合は、RelativeLayout
の高さはどうでもいいですか?子ビューの高さをmatch_parentに設定したときに、間違った親ビューを使用する場合
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@null">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_toStartOf="@+id/vote_container"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:text="1M"/>
</LinearLayout>
<LinearLayout
android:id="@id/vote_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal">
<ImageButton
android:id="@+id/upvote_button"
android:layout_width="30dp"
android:layout_height="17dp"
android:layout_centerHorizontal="true"
android:background="@null"
android:src="@drawable/ic_keyboard_arrow_up"/>
<TextView
android:id="@+id/number_of_votes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/upvote_button"
android:hint="100"/>
<ImageButton
android:id="@+id/downvote_button"
android:layout_width="30dp"
android:layout_height="17dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/number_of_votes"
android:background="@null"
android:src="@drawable/ic_keyboard_arrow_down"/>
</LinearLayout>
</RelativeLayout>
もし私がrelativelayoutの高さをmatch_parentにしたいのであれば、それは –