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,120 +1,127 @@
|
||||||
<?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"
|
||||||
android:orientation="horizontal"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:maxWidth="600dp"
|
||||||
|
app:defaultWidth="350dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="wrap_content">
|
||||||
android:paddingHorizontal="16dp">
|
<LinearLayout
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:paddingHorizontal="16dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/reply_btn"
|
android:id="@+id/reply_btn"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:minWidth="56dp">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/reply"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:minWidth="56dp">
|
||||||
android:drawableStart="@drawable/ic_fluent_chat_multiple_24_selector_text"
|
<TextView
|
||||||
android:drawablePadding="8dp"
|
android:id="@+id/reply"
|
||||||
android:paddingHorizontal="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:drawableTint="?android:textColorSecondary"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textAppearance="@style/m3_label_large"
|
android:drawableStart="@drawable/ic_fluent_chat_multiple_24_selector_text"
|
||||||
tools:text="123"/>
|
android:drawablePadding="8dp"
|
||||||
</FrameLayout>
|
android:paddingHorizontal="8dp"
|
||||||
|
android:drawableTint="?android:textColorSecondary"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textAppearance="@style/m3_label_large"
|
||||||
|
tools:text="123"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/boost_btn"
|
android:id="@+id/boost_btn"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:minWidth="56dp">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/boost"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:minWidth="56dp">
|
||||||
android:drawableStart="@drawable/ic_boost"
|
<TextView
|
||||||
android:drawablePadding="8dp"
|
android:id="@+id/boost"
|
||||||
android:paddingHorizontal="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:drawableTint="@color/boost_icon"
|
android:layout_height="match_parent"
|
||||||
android:textColor="@color/boost_icon"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
android:drawableStart="@drawable/ic_boost"
|
||||||
android:textAppearance="@style/m3_label_large"
|
android:drawablePadding="8dp"
|
||||||
tools:text="123"/>
|
android:paddingHorizontal="8dp"
|
||||||
</FrameLayout>
|
android:drawableTint="@color/boost_icon"
|
||||||
|
android:textColor="@color/boost_icon"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textAppearance="@style/m3_label_large"
|
||||||
|
tools:text="123"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/favorite_btn"
|
android:id="@+id/favorite_btn"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:minWidth="56dp">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/favorite"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:minWidth="56dp">
|
||||||
android:drawableStart="@drawable/ic_fluent_star_24_selector"
|
<TextView
|
||||||
android:drawablePadding="8dp"
|
android:id="@+id/favorite"
|
||||||
android:paddingHorizontal="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:drawableTint="@color/favorite_icon"
|
android:layout_height="match_parent"
|
||||||
android:textColor="@color/favorite_icon"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
android:drawableStart="@drawable/ic_fluent_star_24_selector"
|
||||||
android:textAppearance="@style/m3_label_large"
|
android:drawablePadding="8dp"
|
||||||
tools:text="123"/>
|
android:paddingHorizontal="8dp"
|
||||||
</FrameLayout>
|
android:drawableTint="@color/favorite_icon"
|
||||||
|
android:textColor="@color/favorite_icon"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textAppearance="@style/m3_label_large"
|
||||||
|
tools:text="123"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/bookmark_btn"
|
android:id="@+id/bookmark_btn"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:minWidth="56dp">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/bookmark"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:minWidth="56dp">
|
||||||
android:drawableStart="@drawable/ic_fluent_bookmark_24_selector"
|
<TextView
|
||||||
android:paddingHorizontal="8dp"
|
android:id="@+id/bookmark"
|
||||||
android:drawableTint="@color/bookmark_icon"
|
android:layout_width="wrap_content"
|
||||||
android:gravity="center_vertical"
|
android:layout_height="match_parent"
|
||||||
android:textAppearance="@style/m3_label_large" />
|
android:layout_gravity="center_vertical"
|
||||||
</FrameLayout>
|
android:drawableStart="@drawable/ic_fluent_bookmark_24_selector"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:drawableTint="@color/bookmark_icon"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:textAppearance="@style/m3_label_large" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<Space
|
<Space
|
||||||
android:layout_width="0px"
|
android:layout_width="0px"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
android:layout_weight="1"/>
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/share_btn"
|
android:id="@+id/share_btn"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/share"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:layout_gravity="center_vertical"
|
<ImageView
|
||||||
android:src="@drawable/ic_fluent_share_24_regular"
|
android:id="@+id/share"
|
||||||
android:paddingHorizontal="8dp"
|
android:layout_width="wrap_content"
|
||||||
android:tint="?android:textColorSecondary"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical"/>
|
android:layout_gravity="center_vertical"
|
||||||
</FrameLayout>
|
android:src="@drawable/ic_fluent_share_24_regular"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:tint="?android:textColorSecondary"
|
||||||
|
android:gravity="center_vertical"/>
|
||||||
|
</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