Imagebuttonを持っています。画像ボタンの下に水平線があり、この水平線の下にTextviewがあります。LinearLayoutの中央の画像ボタン
どういうわけか、私はandroid:gravity="center"
を使用してもかかわらず、IMAGEBUTTONをセンタリングすることができず、また、IはIMAGEBUTTONとのTextViewの間の水平線を設定することはできません。 ImageButton
に
about.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="32dp"
android:background="@drawable/roundcorner"
android:gravity="center"
app:srcCompat="@drawable/ic_launcher" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:background="#c0c0c0"
android:foregroundGravity="center_horizontal"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp" />
</LinearLayout>
ありがとうございます、魅力的です。両方の主な違いは何ですか? – Blnpwr
'gravity'は子の重力を指定し、' layout_gravity'は親の重力を指定します。 –
ありがとうございます。私は7分で答えを受け入れることができます、心配しないで、それを忘れることはありません。 – Blnpwr