2016-12-23 1 views
0

Ich habe ein relatives Layout erstellt und Listenansicht oben, bearbeitbaren Text unter Listenansicht und 1 Taste auf der linken Seite bearbeitbaren Text und eine Taste auf der rechten Seite von bearbeitbarem Text platziert.Hinzufügen von Schaltflächen innerhalb von Text bearbeiten Android

Sieht in etwa so aus. HOW ITS LOOKING AT THE MOMENT

Aber ich möchte die Schaltflächen in der bearbeitbaren Textansicht platziert werden. Kann jemand bitte helfen, schätzen Sie wirklich Ihre Zeit.

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="app.com.date.MainActivity"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentStart="true" 
     android:layout_above="@+id/button1" 
     android:id="@+id/listview1" 
     android:stackFromBottom="true" 
     android:transcriptMode="alwaysScroll" 
     android:dividerHeight="0dp" 
     android:divider="@null" /> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:inputType="text" 
     android:ems="10" 
     android:id="@+id/text1" 
     android:layout_toStartOf="@+id/button1" 
     android:textAppearance="@style/TextAppearance.AppCompat" 
     android:freezesText="true" 
     android:textSize="12sp" 
     android:fontFamily="sans-serif" 
     android:layout_alignParentBottom="true" 
     android:layout_below="@+id/listview1" /> 

    <Button 
     android:text="Button" 
     android:layout_width="15dp" 
     android:layout_height="15dp" 
     android:id="@+id/imageButton" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentStart="true" 
     android:layout_below="@+id/listview1" 
     android:layout_toStartOf="@+id/text1" /> 

    <Button 
     android:text="Button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/button1" 
     android:layout_marginEnd="21dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentEnd="true" /> 
</RelativeLayout> 

aber sollte es so aussehen

HOW IT SHOULD LOOK

Danke fürs Lesen. schätzen Sie Ihre Zeit.

+0

Ich bin mir nicht sicher, ob ich den Unterschied zu sehen bin. Der einzige offensichtliche Unterschied ist, dass Ihre Ansichten nicht formatiert sind. Warum sollten Sie die Schaltflächen in den EditText einfügen, anstatt sie links und rechts zu haben? Du bearbeitest die Knöpfe nicht – BR89

+0

Ja, es dient nur dem Styling. Ich möchte den Text wie folgt bearbeiten: https://i.stack.imgur.com/CrZ1w.png – user7327850

+0

Wenn das der Fall ist, ziehen Sie in Betracht, ein Elternteil horizontales 'Lineares Layout' zu erstellen und Ihren Button, EditText, Button darin zu verschachteln. Erstellen Sie einen Rahmen um das 'Linear Layout' und stylen Sie den EditText so, dass er ein bisschen blank ist. – BR89

Antwort

0

Try this:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin"> 

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentStart="true" 
    android:layout_above="@+id/button1" 
    android:id="@+id/listview1" 
    android:stackFromBottom="true" 
    android:transcriptMode="alwaysScroll" 
    android:dividerHeight="0dp" 
    android:divider="@null" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="text" 
    android:ems="10" 
    android:id="@+id/text1" 
    android:textAppearance="@style/TextAppearance.AppCompat" 
    android:freezesText="true" 
    android:textSize="12sp" 
    android:fontFamily="sans-serif" 
    android:layout_alignParentBottom="true" 
    android:layout_below="@+id/listview1" /> 

<Button 
    android:text="Button" 
    android:layout_width="15dp" 
    android:layout_height="15dp" 
    android:id="@+id/imageButton" 
    android:layout_alignParentBottom="true" 
    android:layout_toLeftOf="@+id/button1" 
    android:layout_below="@+id/listview1" /> 

<Button 
    android:text="Button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/button1" 
    android:layout_marginEnd="21dp" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" /> 

Verwandte Themen