2017-11-22 3 views
0

Ich habe 4 Bildansichten miteinander verbunden mit "ToLeftOf" -Befehl. Das Problem ist, wenn ich eine von ihnen unsichtbar mache, die andere an der gleichen Position bleibend oder zur linken Seite des Plans gehend.Moving ImageView nach rechts von 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> 

Ich verwendete animateLayoutChanges = "True", aber es hat nicht funktioniert. Und so machen sie sie unsichtbar oder sichtbar.

if (!marker.getTitle().equals("Buradasın")) { 
        latLngMaps = marker.getPosition(); 
        share.setVisibility(View.VISIBLE); 
        direction.setVisibility(View.VISIBLE); 
        bullet.setVisibility(View.VISIBLE); 
        access.setVisibility(View.VISIBLE); 
       } else { 
        bullet.setVisibility(View.VISIBLE); 
        share.setVisibility(View.INVISIBLE); 
        direction.setVisibility(View.INVISIBLE); 
        access.setVisibility(View.INVISIBLE); 
       } 

Was tun möchte, ist können sagen, sie wie X Y Z Q bleiben wenn ich Y unsichtbar machen es wie X Z F sein muss Es wird nur der Platz des unsichtbaren gehen. Danke fürs Helfen.

Antwort

1

Setzen Sie eine LinearLayout mit einer Orientierung horizontal:

<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> 

Und stellen Sie die Sichtbarkeit auf GONE statt INVISIBLE:

  if (!marker.getTitle().equals("Buradasın")) { 
       latLngMaps = marker.getPosition(); 
       share.setVisibility(View.VISIBLE); 
       direction.setVisibility(View.VISIBLE); 
       bullet.setVisibility(View.VISIBLE); 
       access.setVisibility(View.VISIBLE); 
      } else { 
       bullet.setVisibility(View.VISIBLE); 
       share.setVisibility(View.GONE); 
       direction.setVisibility(View.GONE); 
       access.setVisibility(View.GONE); 
      } 
+0

Es hat funktioniert. Wie kann ich alle Bilder nach rechts verschieben? Sie stehen jetzt auf der linken Seite. –

+0

Ich weiß nicht, was Ihre App tut, und wenn es zutrifft, sollte 'android: layoutDirection =" rtl "' auf Ihren 'LinearLayout'-Attributen dies tun (dieses Flag wird angewendet, egal ob die Sprache des Benutzers richtig ist nach links oder von links nach rechts) – mVck

1

Wenn Sie möchten, dass die Ansichten den Raum nicht ausfüllen, wenn er ausgeblendet ist, sollten Sie GONE statt INVISIBLE verwenden.

access.setVisibility(View.GONE); 

https://developer.android.com/reference/android/transition/Visibility.html \

UPDATE

der Behälter der Bildansicht Layouts auszutauschen, ersetzen diese:

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/relative" 
     android:layout_gravity="bottom" 
     android:layout_marginBottom="85dp"> 

Hierdurch:

<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"> 
+0

es noch gleiche. die Bildansicht, die sichtbar bleibt, geht nach links –

+0

Überprüfen Sie meine aktualisierte Antwort – diegoveloper

+0

es ist immer noch der gleiche Mann:/ –

Verwandte Themen