Java 将ImageView移动到布局的右侧
我有4个图像视图通过“toLeftOf”命令相互连接。问题是,当我使其中一个不可见时,另一个保持在相同的位置,或者转到布局的左侧Java 将ImageView移动到布局的右侧,java,android,xml,maps,Java,Android,Xml,Maps,我有4个图像视图通过“toLeftOf”命令相互连接。问题是,当我使其中一个不可见时,另一个保持在相同的位置,或者转到布局的左侧 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_
<FrameLayout 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"
tools:context=".MapsActivity" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ahmetbesli.eczanem.MapsActivity" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relative"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/direction"
android:src="@drawable/ic_directions_black_24dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:visibility="visible"
android:background="@drawable/rounded_corner"
android:animateLayoutChanges="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bullet"
android:src="@drawable/ic_format_align_left_black_24dp"
android:layout_toLeftOf="@+id/direction"
android:layout_toStartOf="@+id/direction"
android:visibility="visible"
android:background="@drawable/rounded_corner"
android:layout_marginRight="1dp"
android:layout_marginEnd="1dp"
android:animateLayoutChanges="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/share"
android:src="@drawable/ic_share_black_24dp"
android:layout_toLeftOf="@+id/bullet"
android:layout_toStartOf="@+id/bullet"
android:visibility="visible"
android:background="@drawable/rounded_corner"
android:layout_marginRight="1dp"
android:layout_marginEnd="1dp"
android:animateLayoutChanges="true"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/access"
android:src="@drawable/ic_accessibility_black_24dp"
android:layout_toLeftOf="@+id/share"
android:layout_toStartOf="@+id/share"
android:visibility="visible"
android:background="@drawable/rounded_corner"
android:layout_marginRight="1dp"
android:layout_marginEnd="1dp"
android:animateLayoutChanges="true"/>
</RelativeLayout>
</FrameLayout>
我们想做的是,让我们说他们像X Y Z Q一样呆着
当我使Y隐形时,它一定像xzq。它只会穿过隐形的地方。谢谢您的帮助。如果您希望视图在隐藏时不会填满空间,您应该使用
GONE
而不是INVISIBLE
access.setVisibility(View.GONE);
\
更新
替换imageview布局的容器,替换此:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relative"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp">
据此:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relative"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp">
如果您希望视图在隐藏时不会填满空间,则应使用
GONE
而不是INVISIBLE
access.setVisibility(View.GONE);
\
更新
替换imageview布局的容器,替换此:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relative"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp">
据此:
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/relative"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp">
将其替换为具有水平方向的
线性布局
:
<LinearLayout
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_directions_black_24dp"/>
<ImageView
android:id="@+id/bullet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_format_align_left_black_24dp"/>
<ImageView
android:id="@+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_share_black_24dp" />
<ImageView
android:id="@+id/access"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_accessibility_black_24dp" />
</LinearLayout>
将其替换为具有水平方向的
线性布局
:
<LinearLayout
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="85dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_directions_black_24dp"/>
<ImageView
android:id="@+id/bullet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_format_align_left_black_24dp"/>
<ImageView
android:id="@+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_share_black_24dp" />
<ImageView
android:id="@+id/access"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/rounded_corner"
android:src="@drawable/ic_accessibility_black_24dp" />
</LinearLayout>
还是一样。保持可见的imageview将向左移动,但仍保持不变。保持可见的imageview将在工作时向左移动。如何将所有图像移到右侧?他们现在站在左边。我不知道你的应用程序做什么,也不知道它是否适用,但是
android:layoutDirection=“rtl”
在你的LinearLayout
属性上应该可以做到这一点(无论用户的语言是从右向左还是从左向右),这个标志都会适用)。如何将所有图像移到右侧?他们现在站在左边。我不知道你的应用程序做什么,也不知道它是否适用,但是android:layoutDirection=“rtl”
在你的LinearLayout
属性上应该这样做(无论用户的语言是从右向左还是从左向右,这个标志都会适用)