Commit 2ca8d50e authored by Mygod's avatar Mygod

Refine layout for wide screens

parent 3a66bbba
......@@ -27,8 +27,9 @@
android:paddingEnd="72dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.GridLayout android:layout_width="match_parent"
<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"
......@@ -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>
<?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"
<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"
......@@ -74,4 +78,5 @@
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</com.github.shadowsocks.widget.BoundedCardView>
</FrameLayout>
<?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
......
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)
}
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)
}
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)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment