2017-02-06 2 views
0

Dies kann dumme Frage sein, aber ich konnte keine Lösung für mein Problem finden, lassen Sie mich mein Problem zu erklären versuchen, kleine quadratische Schaltfläche auf der rechten Seite des Textes wie im Bild unten ausgerichtet habe ich viele Dinge ausprobiert, aber nichts hat mir geholfen lassen Sie mich, was ich bisher versucht habe:Wie man kleine quadratische Taste rechts von Textview ausrichtet?

<RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/content_spare_request" 
     android:background="#fff" 
     android:layout_marginBottom="20dp" 
     android:layout_margin="10dp" 
     android:layout_below="@+id/root1"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:id="@+id/spare_text" 
      android:layout_marginStart="2sp" 
      android:paddingLeft="10dp" 
      android:layout_marginTop="07dp" 
      android:text="@string/Spare" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="@color/SForange" 
      android:textSize="16sp" /> 
     <Button 
      android:id="@+id/btn_spare" 
      android:layout_width="20dp" 
      android:layout_height="match_parent" 
      android:minHeight="0dp" 
      android:minWidth="0dp" 
      android:background="@color/SForange" 
      android:layout_alignParentRight="true" 
      /> 

     <View 
      android:layout_width="match_parent" 
      android:layout_height="3dp" 
      android:id="@+id/view2" 
      android:layout_below="@+id/spare_text" 
      android:background="@color/SForange" 
      android:gravity="center" /> 
     <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:id="@+id/spare_recyclerview" 
      android:layout_below="@+id/view2" 
      android:layout_height="wrap_content"/> 
     <TextView 
      android:id="@+id/empty_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:paddingBottom="75dp" 
      android:gravity="center_horizontal" 
      android:layout_below="@+id/view2" 
      android:visibility="visible" 
      android:text="No Data Available" 
      /> 

    </RelativeLayout> 
+0

Verwenden Sie 'DrawableRight' – hrskrs

+0

Könnten Sie bitte @hrskrs dann erarbeiten, wie man klickbare –

+0

Sie wollen die Plus-Taste auf der rechten Seite? –

Antwort

0

Sie können unter den Dingen tun.

  1. Breite des relativen Layouts als match_parent machen.
  2. Legen Sie btn_spare als rechts ausgerichtet und Textansicht zum Starten von btn_spare.
+0

Ich habe schon versucht, diese Dada aber nicht funktioniert !! –

+0

Sie müssen Ihre Textansicht und Schaltfläche in ein anderes relatives Layout einfügen. Tun Sie dies wird es funktionieren –

+0

Danke Dada für Ihre Antwort! –

0

ConstraintLayout verwenden. Sie erhalten die Möglichkeit, den genauen Standort der Ansicht zu definieren. Wenn Sie zum Beispiel eine Schaltfläche unter der Bildansicht mit einem bestimmten Abstand zwischen ihnen möchten, erhalten Sie mit ConstraintLayout etwas Ähnliches.

enter image description here

0

nicht match_parent für Knopfhöhe anwenden. Ändern Sie Ihre Button Höhe von match_parent zu bestimmten Höhe und fügen android_background es:

<Button 
    android:id="@+id/btn_spare" 
    android:layout_width="35dp" 
    android:layout_height="35dp" 
    android:minHeight="0dp" 
    android:minWidth="0dp" 
    android:background="@mipmap/ic_launcher" 
    android:layout_alignParentRight="true" 
    /> 

Ausgang:

enter image description here

+0

Danke für Ihre Antwort! –

+0

@ M.Yogeshwaran Erwägen Sie die Annahme der Antwort, wenn geholfen oder upvotes – W4R10CK

0

versucht, diese

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/content_spare_request" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/root1" 
    android:layout_margin="10dp" 
    android:orientation="vertical" 
    android:layout_marginBottom="20dp" 
    android:background="#fff"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/spare_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginStart="2sp" 
      android:layout_marginTop="07dp" 
      android:paddingLeft="10dp" 
      android:text="@string/tip_brush_size" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="@color/facebook" 
      android:textSize="16sp" /> 

     <Button 
      android:id="@+id/btn_spare" 
      android:layout_width="20dp" 
      android:layout_height="match_parent" 
      android:background="@color/facebook" 
      android:layout_alignParentRight="true" 
      android:minHeight="0dp" 
      android:minWidth="0dp" /> 
    </RelativeLayout> 


    <View 
     android:id="@+id/view2" 
     android:layout_width="match_parent" 
     android:layout_height="3dp" 
     android:layout_below="@+id/spare_text" 
     android:background="@color/facebook" 
     android:gravity="center" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/spare_recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/view2" /> 

    <TextView 
     android:id="@+id/empty_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:gravity="center_horizontal" 
     android:paddingBottom="75dp" 
     android:text="No Data Available" 
     android:visibility="visible" /> 

</LinearLayout> 
+0

den Farbnamen ändern. –

+0

danke ajay danke für deine antwort –

0

Versuchen Sie, diese

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/content_spare_request" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/root1" 
    android:layout_margin="10dp" 
    android:layout_marginBottom="20dp" 
    android:background="#fff"> 

    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="match_parent" 
     android:layout_height="40dp" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/spare_text" 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:paddingLeft="10dp" 
      android:text="@string/Spare" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:textColor="@color/SForange" 
      android:textSize="16sp" /> 

     <Button 
      android:id="@+id/btn_spare" 
      android:layout_width="40dp" 
      android:layout_height="match_parent" 
      android:background="@color/SForange" 
      android:minHeight="0dp" 
      android:minWidth="0dp" /> 

    </LinearLayout> 


    <View 
     android:id="@+id/view2" 
     android:layout_width="match_parent" 
     android:layout_height="3dp" 
     android:layout_below="@+id/header" 
     android:background="@color/SForange" 
     android:gravity="center" /> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/spare_recyclerview" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/view2" /> 

    <TextView 
     android:id="@+id/empty_view" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/view2" 
     android:gravity="center_horizontal" 
     android:paddingBottom="75dp" 
     android:text="No Data Available" 
     android:visibility="visible" /> 

</RelativeLayout> 
+0

magizhchi ich arbeite vielen dank –

Verwandte Themen