【发布时间】:2017-09-24 17:27:35
【问题描述】:
我有一个 Imagebutton,一条水平线应该在 imagebutton 下方,在这条水平线下方我有一个 Textview。
不知何故,尽管使用了android:gravity="center",但我无法将 Imagebutton 居中
而且我也无法在 Imagebutton 和 TextView 之间设置水平线。请帮忙
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>
【问题讨论】: