你好,我想在android studio中用线性布局把两个按钮放在一起。
<LinearLayout 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:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="222dp"
android:layout_height="237dp"
app:srcCompat="@drawable/ic_launcher_background"
tools:layout_editor_absoluteX="246dp"
tools:layout_editor_absoluteY="322dp" />
<com.google.android.material.button.MaterialButton
android:id="@+id/cameraBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/camera"
android:layout_marginTop="8dp"
app:strokeColor="@color/teal_700"
app:cornerRadius="100dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/galleryBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gallery"
android:layout_marginTop="8dp"
app:cornerRadius="100dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
the output currently is:
我试着用相对布局--没有用,也用线性布局中的水平布局。
我试着把android:layout_weight也设为1,结果按钮消失了。
我想把imageview放在中间,下面有两个按钮,两个按钮挨在一起。