2017-01-12 2 views
0

Ich erstelle einen Benutzerprofilbildschirm in Android. In diesem Bildschirm haben Benutzerprofil Hintergrund und Benutzerprofil Bild. Hier ist der graue Hintergrund Profiltapete und roter Hintergrund wird zum Profilbild. Ich brauche das rote bg Layout zur horizontalen und vertikalen Mitte des grauen bg Layouts einstellen ..Horizontale und vertikale Mitte zum übergeordneten Layout

enter image description here

<?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" 
android:id="@+id/rlActivityNotificationsAndProfile"> 
<include layout="@layout/layout_tool_bar"/> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/profile_wallpaper_container_height" 
    android:id="@+id/rlProfileWallpaper" 
    android:layout_below="@+id/toolbar"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:background="#646464" 
     android:orientation="vertical" 
     android:layout_height="@dimen/profile_wallpaper_height"> 
     <LinearLayout 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:background="#A52525"> 
     </LinearLayout> 
</LinearLayout> 
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/tools" 
     android:id="@+id/fabEditProfile" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_margin="@dimen/base_ten_dp" 
     android:layout_marginEnd="@dimen/base_ten_dp" 
     android:layout_marginStart="@dimen/base_ten_dp" 
     android:scaleType="center" 
     android:src="@drawable/add" 
     app:elevation="@dimen/priority_1_elevation" 
     app:fabSize="1"/> 
</RelativeLayout> 
</LinearLayout> 
+1

Verwenden 'android: Schwerkraft = "center"' für Eltern 'LinearLayout' statt –

+0

Viele @RomanKolomenskii Sie –

+0

@RomanKolomenskii wenn OP bestätigt Ihre Lösung (tut ihn?), bitte eine Antwort von Ihrem Kommentar so OP machen kann es als abgeschlossen markieren. –

Antwort

1

können Sie legen einfach Ihre Eltern Linearlayout Schwerkraft zum Zentrum (nur 1 Zeile hinzugefügt werden):

<?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" 
android:id="@+id/rlActivityNotificationsAndProfile"> 
<include layout="@layout/layout_tool_bar"/> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/profile_wallpaper_container_height" 
    android:id="@+id/rlProfileWallpaper" 
    android:layout_below="@+id/toolbar"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:background="#646464" 
     android:orientation="vertical" 
     android:layout_height="@dimen/profile_wallpaper_height" 
     android:gravity="center"> 
     <LinearLayout 
      android:layout_width="30dp" 
      android:layout_height="30dp" 
      android:layout_gravity="center" 
      android:background="#A52525"> 
     </LinearLayout> 
</LinearLayout> 
<android.support.design.widget.FloatingActionButton xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/tools" 
     android:id="@+id/fabEditProfile" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_margin="@dimen/base_ten_dp" 
     android:layout_marginEnd="@dimen/base_ten_dp" 
     android:layout_marginStart="@dimen/base_ten_dp" 
     android:scaleType="center" 
     android:src="@drawable/add" 
     app:elevation="@dimen/priority_1_elevation" 
     app:fabSize="1"/> 
</RelativeLayout> 
</LinearLayout> 
+0

danke .. seine Arbeit ... –

Verwandte Themen