mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-12-01 12:31:45 +00:00
Make the searchbar use the full available width (#7944)
This commit is contained in:
@ -6,6 +6,6 @@
|
||||
android:id="@+id/action_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
app:showAsAction="collapseActionView|always"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:actionViewClass="de.danoeh.antennapod.ui.common.CollapsibleSearchView"
|
||||
android:title="@string/search_label"/>
|
||||
</menu>
|
||||
@ -0,0 +1,37 @@
|
||||
package de.danoeh.antennapod.ui.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.CollapsibleActionView;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
|
||||
/**
|
||||
* A SearchView implementation that can be used as an expanded action view.
|
||||
* It overrides the default behavior to take the full width of the screen.
|
||||
*/
|
||||
public class CollapsibleSearchView extends SearchView implements CollapsibleActionView {
|
||||
public CollapsibleSearchView(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public CollapsibleSearchView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public CollapsibleSearchView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionViewExpanded() {
|
||||
super.onActionViewExpanded();
|
||||
ViewGroup.LayoutParams params = getLayoutParams();
|
||||
if (params != null) {
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
setLayoutParams(params);
|
||||
}
|
||||
setIconifiedByDefault(false);
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,7 @@
|
||||
android:id="@+id/action_search"
|
||||
android:icon="@drawable/ic_search"
|
||||
custom:showAsAction="collapseActionView|ifRoom"
|
||||
custom:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
custom:actionViewClass="de.danoeh.antennapod.ui.common.CollapsibleSearchView"
|
||||
android:title="@string/search_label"/>
|
||||
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user