Refine layout for wide screens
This commit is contained in:
@@ -27,9 +27,10 @@
|
||||
android:paddingEnd="72dip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<android.support.v7.widget.GridLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:columnCount="4">
|
||||
<com.github.shadowsocks.widget.BoundedGridLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:bounded_width="288dp"
|
||||
app:columnCount="4">
|
||||
<TextView app:layout_column="0" style="@style/TextAppearance.AppCompat.Body2"
|
||||
android:ellipsize="marquee" android:text="@string/sent"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
@@ -63,7 +64,7 @@
|
||||
android:textColor="?android:attr/textColorSecondary" android:ellipsize="marquee"
|
||||
android:layout_width="0dp" android:layout_height="wrap_content" app:layout_columnWeight="1"
|
||||
app:layout_gravity="fill_horizontal" android:gravity="end"/>
|
||||
</android.support.v7.widget.GridLayout>
|
||||
</com.github.shadowsocks.widget.BoundedGridLayout>
|
||||
</LinearLayout>
|
||||
<com.github.jorgecastilloprz.FABProgressCircle android:id="@+id/fabProgressCircle"
|
||||
app:reusable="true"
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="32dp"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,77 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Based on: https://github.com/android/platform_frameworks_base/blob/505e3ab/core/res/res/layout/simple_list_item_2.xml -->
|
||||
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/background_selectable"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:id="@+id/indicator">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:focusable="true"
|
||||
android:nextFocusRight="@+id/edit"
|
||||
android:id="@+id/content"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<com.github.shadowsocks.widget.BoundedCardView android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/background_selectable"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
app:bounded_width="480dp"
|
||||
android:id="@+id/indicator">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/container">
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp"
|
||||
android:focusable="true"
|
||||
android:nextFocusRight="@+id/edit"
|
||||
android:id="@+id/content"
|
||||
android:background="?android:attr/selectableItemBackground">
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"/>
|
||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:layout_gravity="top"
|
||||
app:srcCompat="@drawable/ic_social_share"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="Share"
|
||||
android:focusable="true"
|
||||
android:nextFocusLeft="@+id/container"/>
|
||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:id="@+id/container">
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"/>
|
||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/share"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:layout_gravity="top"
|
||||
app:srcCompat="@drawable/ic_social_share"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="Share"
|
||||
android:focusable="true"
|
||||
android:nextFocusLeft="@+id/container"/>
|
||||
<android.support.v7.widget.AppCompatImageView android:id="@+id/edit"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:layout_gravity="top"
|
||||
app:srcCompat="@drawable/ic_image_edit"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="Edit"
|
||||
android:focusable="true"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:layout_gravity="top"
|
||||
app:srcCompat="@drawable/ic_image_edit"
|
||||
android:background="?attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="Edit"
|
||||
android:focusable="true"/>
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:id="@+id/details">
|
||||
<TextView android:id="@+id/address"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:layout_weight="1"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
<TextView android:id="@+id/traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
<LinearLayout android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:id="@+id/details">
|
||||
<TextView android:id="@+id/address"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:layout_weight="1"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
<TextView android:id="@+id/traffic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:ellipsize="end"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
</com.github.shadowsocks.widget.BoundedCardView>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="BoundedView">
|
||||
<attr name="bounded_width" format="dimension" />
|
||||
<attr name="bounded_height" format="dimension" />
|
||||
</declare-styleable>
|
||||
<declare-styleable name="NumberPickerPreference">
|
||||
<attr name="max" format="integer" />
|
||||
<attr name="min" format="integer" />
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.GregorianCalendar
|
||||
import android.content._
|
||||
import android.os.{Bundle, Handler}
|
||||
import android.support.v4.content.LocalBroadcastManager
|
||||
import android.support.v7.widget.{DefaultItemAnimator, LinearLayoutManager, RecyclerView, Toolbar}
|
||||
import android.support.v7.widget._
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder
|
||||
import android.support.v7.widget.helper.ItemTouchHelper
|
||||
import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.github.shadowsocks.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.CardView
|
||||
import android.util.AttributeSet
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
*/
|
||||
class BoundedCardView(context: Context, attrs: AttributeSet) extends CardView(context, attrs) with BoundedView {
|
||||
initAttrs(context, attrs)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.github.shadowsocks.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.widget.GridLayout
|
||||
import android.util.AttributeSet
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
*/
|
||||
class BoundedGridLayout(context: Context, attrs: AttributeSet) extends GridLayout(context, attrs) with BoundedView {
|
||||
initAttrs(context, attrs)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.github.shadowsocks.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.View.MeasureSpec
|
||||
import com.github.shadowsocks.R
|
||||
|
||||
/**
|
||||
* Based on: http://stackoverflow.com/a/6212120/2245107
|
||||
*
|
||||
* @author Mygod
|
||||
*/
|
||||
trait BoundedView extends View {
|
||||
private var boundedWidth: Int = _
|
||||
private var boundedHeight: Int = _
|
||||
|
||||
protected def initAttrs(context: Context, attrs: AttributeSet) {
|
||||
val arr = context.obtainStyledAttributes(attrs, R.styleable.BoundedView)
|
||||
boundedWidth = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_width, 0)
|
||||
boundedHeight = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_height, 0)
|
||||
arr.recycle()
|
||||
}
|
||||
|
||||
override def onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit = super.onMeasure(
|
||||
if (boundedWidth > 0 && boundedWidth < MeasureSpec.getSize(widthMeasureSpec))
|
||||
MeasureSpec.makeMeasureSpec(boundedWidth, MeasureSpec.getMode(widthMeasureSpec))
|
||||
else widthMeasureSpec,
|
||||
if (boundedHeight > 0 && boundedHeight < MeasureSpec.getSize(heightMeasureSpec))
|
||||
MeasureSpec.makeMeasureSpec(boundedHeight, MeasureSpec.getMode(heightMeasureSpec))
|
||||
else heightMeasureSpec)
|
||||
}
|
||||
Reference in New Issue
Block a user