- Forum-Beiträge: 12
17.06.2020, 21:13:58 via Website
17.06.2020 21:13:58 via Website
Hallo
ich habe eine menu.xml für die ActionBar
<menu xmlns:android="schemas.android.com/apk/res/android"
xmlns:app="schemas.android.com/apk/res-auto"
xmlns:tools="schemas.android.com/tools"
tools:context="com.example.projecttime.MainActivity">
<item
android:id="@+id/ItemSearch"
android:title="@string/search"
app:actionLayout="@layout/searchfield"
app:showAsAction="always"/>
<item
android:id="@+id/ItemRefresh"
android:icon="@drawable/ic_refresh"
android:title="@string/refresh"
app:showAsAction="always" />
Dann die searchfield.xml
<LinearLayout xmlns:android="schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PT"
android:visibility="visible"
android:textColor="@color/colorWhite"
android:textSize="24sp"
android:textStyle="bold"
android:shadowColor="@color/colorBlack"
android:shadowDx="0.0"
android:shadowDy="0.0"
android:shadowRadius="15.0"
android:layout_marginRight="@dimen/abstand_halb">
</TextView>
<EditText
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cursorVisible="true"
android:ems="8"
android:imeOptions="actionDone"
android:inputType="text"
android:textColor="@android:color/black"
android:visibility="invisible"
android:drawableRight="@drawable/ic_et_cancle1"
android:layout_marginRight="@dimen/abstand_halb">
</EditText>
<ImageView
android:id="@+id/imgSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_searching"
android:layout_marginRight="@dimen/abstand_standard"
android:onClick="imgSearchOnClick"/>
Das LinearLayout hat match_parent für die BReite. Beim Start der App wird der Platz voll ausgenutzt und alles sieht gut aus. Drehe ich aber das Display, aktualisiert sich die Breite nicht.
Durch match_parent hätte ich erwartet, dass die Breite sich anpasst. Vom rechten Rand aus gesehen, wird also nur der Platz genutzt, wie bei der Hochkantansicht. Das TextView Element steht also mitten in der ActionBar und leider nicht links
Kann man das irgendwie lösen?
Christof
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.