我想在谷歌地图下方并排显示两张图片。图片显示正常。但图像显示同一侧。我想在两张图片中间显示一些文字。
我想在 View 的右侧显示第二张图片,在中间显示文本。
当前代码
<?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_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@color/bt_white">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginStart="5dp"
android:src="@drawable/ic_menu_camera"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:text="@string/action_settings"/>
</LinearLayout>
<ImageView
android:id="@+id/imageView12"
android:layout_width="80dp"
android:layout_height="80dp"
android:gravity="right"
android:src="@drawable/ic_menu_camera" />
</LinearLayout>
</LinearLayout>
最佳答案
这是你的布局
<?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_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/bt_white"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_marginStart="5dp"
android:src="@android:drawable/ic_menu_camera" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="First Text View"
android:textColor="@color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Second Text view"
android:textColor="@color/black" />
</LinearLayout>
<ImageView
android:id="@+id/imageView12"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_camera" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
这是它的样子
关于android - 如何在android中的LinearLayout内左右对齐2张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45918903/