Ich weiß, es gibt viele Threads mit mehr oder weniger gleichen Thema, aber keiner von ihnen deckt meine Situation:Wie wird das Bildsymbol in einem linearen Layout ausgerichtet?
Ich habe ein wenig Mülleimer für die Schaltfläche löschen, aber es verschwindet immer vom Bildschirm, wenn die Zeile des Textes ist zu lang und wenn es zu kurz ist es an der Linie befestigt und ich wollte nur auf der rechten Seite der App wie der Add_item Button sein, aber da es in einem linearen Layout ist, funktioniert es nicht
ativity_main .xml
<RelativeLayout 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"
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="com.example.owner.test24.MainActivity">
<TextView
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/header"
android:gravity="center_vertical"
android:textColor="@color/accent"
android:textSize="24sp" />
<ImageButton
android:id="@+id/add_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:layout_alignEnd="@+id/header"
android:layout_alignRight="@+id/header"
android:src="@drawable/add_item_button"
android:contentDescription="@string/add_item"/>
<ListView
android:id="@+id/todo_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/header"/>
</RelativeLayout>
to_do_item_layout.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"/>
<ImageButton
android:id="@+id/btnDel"
android:src="@drawable/ic_delete_button"
android:background="@android:color/transparent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete"
/>
wenn jemand Lösung hat lass es mich wissen.
@ M.Bill, wenn es funktioniert bitte upvote – shahid17june
Warum muss ich Gewicht für alle Ansichten hinzufügen, wie Checkbox und ImageButton Breite sind fast in der Größe fixiert? –
Ich wusste es. Aber ist es notwendig für eine feste Ansicht? Ich kann das hinzufügen, wenn alle Ansichten Breite dynamisch sind. –