responsive footer width
This commit is contained in:
parent
44a4d02815
commit
486eef21dd
|
@ -3,12 +3,13 @@ package org.joinmastodon.android.ui.views;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
|
|
||||||
public class MaxWidthFrameLayout extends FrameLayout{
|
public class MaxWidthFrameLayout extends FrameLayout{
|
||||||
private int maxWidth;
|
private int maxWidth, defaultWidth;
|
||||||
|
|
||||||
public MaxWidthFrameLayout(Context context){
|
public MaxWidthFrameLayout(Context context){
|
||||||
this(context, null);
|
this(context, null);
|
||||||
|
@ -22,6 +23,7 @@ public class MaxWidthFrameLayout extends FrameLayout{
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.MaxWidthFrameLayout);
|
TypedArray ta=context.obtainStyledAttributes(attrs, R.styleable.MaxWidthFrameLayout);
|
||||||
maxWidth=ta.getDimensionPixelSize(R.styleable.MaxWidthFrameLayout_android_maxWidth, Integer.MAX_VALUE);
|
maxWidth=ta.getDimensionPixelSize(R.styleable.MaxWidthFrameLayout_android_maxWidth, Integer.MAX_VALUE);
|
||||||
|
defaultWidth=ta.getDimensionPixelSize(R.styleable.MaxWidthFrameLayout_defaultWidth, -1);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +35,19 @@ public class MaxWidthFrameLayout extends FrameLayout{
|
||||||
this.maxWidth=maxWidth;
|
this.maxWidth=maxWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDefaultWidth() {
|
||||||
|
return defaultWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultWidth(int defaultWidth) {
|
||||||
|
this.defaultWidth = defaultWidth;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec){
|
||||||
if(MeasureSpec.getSize(widthMeasureSpec)>maxWidth){
|
if(MeasureSpec.getSize(widthMeasureSpec)>maxWidth){
|
||||||
widthMeasureSpec=maxWidth | MeasureSpec.getMode(widthMeasureSpec);
|
int width = defaultWidth >= 0 ? defaultWidth : maxWidth;
|
||||||
|
widthMeasureSpec=width | MeasureSpec.getMode(widthMeasureSpec);
|
||||||
}
|
}
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<org.joinmastodon.android.ui.views.MaxWidthFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:maxWidth="600dp"
|
||||||
|
app:defaultWidth="350dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
|
@ -118,3 +124,4 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
</org.joinmastodon.android.ui.views.MaxWidthFrameLayout>
|
|
@ -73,6 +73,7 @@
|
||||||
|
|
||||||
<declare-styleable name="MaxWidthFrameLayout">
|
<declare-styleable name="MaxWidthFrameLayout">
|
||||||
<attr name="android:maxWidth" format="dimension"/>
|
<attr name="android:maxWidth" format="dimension"/>
|
||||||
|
<attr name="defaultWidth" format="dimension" />
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
|
|
||||||
<declare-styleable name="FloatingHintEditTextLayout">
|
<declare-styleable name="FloatingHintEditTextLayout">
|
||||||
|
|
Loading…
Reference in New Issue