0

Ich versuche, ein RelativeLayout mit zwei ImageButtons in einem FrameLayout zu platzieren, das bereits über ein ImageView und ein LinearLayout verfügt. Ich muss das Relative Layout so platzieren, dass die obere Hälfte des ImageButton das ImageView überlappt und die untere Hälfte das LineLayout überlappt.Platzieren Sie Schaltflächen zwischen zwei Layouts im Android-Rahmenlayout

Meine aktuelle Layout ist wie folgt:

enter image description here

Mein aktueller xml ist:

<?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="wrap_content" 
    android:background="#f2f2f2" 
    android:elevation="8dp" 
    android:orientation="vertical"> 


    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:background="#fff" 
     android:orientation="vertical"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="180dp" 
        android:src="@drawable/fire_icon" /> 


       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:background="@color/colorblue" 
        android:orientation="vertical" 
        android:padding="10dp" 
        android:layout_margin="10dp"> 

        <TextView 
         android:id="@+id/title" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_weight="1" 
         android:text="Need Help" 
         android:textColor="@color/colortitletext" 
         android:textSize="18sp" 
         android:textStyle="bold" /> 


        <TextView 
         android:id="@+id/description" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="8dp" 
         android:text="Hello, I am trying to create a android layout." 
         android:textColor="@color/colorheadtext" 
         android:textSize="18sp" /> 

       </LinearLayout> 


      </LinearLayout> 
      <RelativeLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center|right" 
       android:layout_marginRight="15dp"> 

       <ImageView 
        android:id="@+id/imageView4" 
        android:layout_width="60dp" 
        android:layout_height="50dp" 
        android:layout_alignParentTop="true" 
        android:layout_toLeftOf="@+id/imageView3" 
        android:layout_toStartOf="@+id/imageView3" 
        android:src="@drawable/ic_menu_camera" /> 

       <ImageView 
        android:id="@+id/imageView3" 
        android:layout_width="60dp" 
        android:layout_height="50dp" 
        android:layout_alignParentEnd="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentTop="true" 
        android:src="@drawable/ic_menu_gallery" /> 

      </RelativeLayout> 
     </FrameLayout> 


    </android.support.v7.widget.CardView> 

</LinearLayout> 

erwartete Layout ist: enter image description here

+0

Blick auf meine Antwort haben ... .... – sushildlh

Antwort

2

Look habe ich Ihr Layout bearbeiten .. ....

ich denke, das ist, was Sie wollen ..........

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#f2f2f2" 
    android:elevation="8dp" 
    android:orientation="vertical"> 


    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_margin="10dp" 
     android:background="#fff" 
     android:orientation="vertical"> 

     <FrameLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 

       <ImageView 
        android:layout_width="match_parent" 
        android:layout_height="180dp" 
        android:src="@drawable/fire_icon"/> 


       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="bottom" 
        android:background="#AACCAA" 
        android:orientation="vertical" 
        android:padding="10dp" 
        android:layout_margin="10dp"> 

        <TextView 
         android:id="@+id/title" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_gravity="center" 
         android:layout_weight="1" 
         android:text="Need Help" 
         android:textColor="@color/colortitletext" 
         android:textSize="18sp" 
         android:textStyle="bold" /> 


        <TextView 
         android:id="@+id/description" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:layout_marginTop="8dp" 
         android:text="Hello, I am trying to create a android layout." 
         android:textColor="@color/colorheadtext" 
         android:textSize="18sp" /> 

       </LinearLayout> 


      </LinearLayout> 
      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="#f2f2f2" 
       android:layout_marginTop="160dp" 
       android:layout_marginLeft="200dp"> 

       <ImageView 
        android:id="@+id/imageView4" 
        android:layout_width="60dp" 
        android:layout_height="50dp" 
        android:src="@drawable/ic_menu_gallery"/> 


       <ImageView 
        android:id="@+id/imageView3" 
        android:layout_width="60dp" 
        android:layout_height="50dp" 
        android:src="@drawable/ic_menu_camera"/> 

      </LinearLayout> 
     </FrameLayout> 


    </android.support.v7.widget.CardView> 

</LinearLayout> 

genießen Codierung ...........

+0

Danke Sushil. Aber kann dies ohne Margen gemacht werden? Ich meine eine relative Positionierung, um dies zu erreichen. –

+0

Frame-Layout arbeiten am Rand nur ohne Rand gibt es viel Problem wie Telefon verschiedene Pixel, und die Sichtbarkeit unterscheiden sich von Gerät zu Gerät und etc. Ich denke, es ist nicht möglich für Rahmenlayout ohne Rand seine Ansichten eingestellt. – sushildlh

Verwandte Themen