Replace hardcoded dimens with dimen resources

This commit is contained in:
Phillip Hsu 2016-08-30 17:24:25 -07:00
parent a7af4f84bb
commit e025f70965
4 changed files with 15 additions and 17 deletions

View File

@ -30,6 +30,8 @@ public class TimersFragment extends RecyclerViewFragment<
TimerViewHolder,
TimerCursor,
TimersCursorAdapter> {
// TODO: Different number of columns for different display densities, instead of landscape.
// Use smallest width qualifiers. I can imagine 3 or 4 columns for a large enough tablet in landscape.
private static final int LANDSCAPE_LAYOUT_COLUMNS = 2;
public static final int REQUEST_CREATE_TIMER = 0;
@ -47,15 +49,10 @@ public class TimersFragment extends RecyclerViewFragment<
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
final Resources r = getResources();
RecyclerView list = findById(view, R.id.list);
int cardViewMargin = r.getDimensionPixelSize(R.dimen.cardview_margin);
switch (getOrientation(r)) {
case Configuration.ORIENTATION_LANDSCAPE:
list.setPaddingRelative(cardViewMargin/*start*/, cardViewMargin/*top*/, 0, list.getPaddingBottom());
break;
case Configuration.ORIENTATION_PORTRAIT:
// list.setPaddingRelative(0, 0, 0, cardViewMargin);
break;
if (getOrientation(r) == Configuration.ORIENTATION_LANDSCAPE) {
RecyclerView list = findById(view, R.id.list);
int cardViewMargin = r.getDimensionPixelSize(R.dimen.cardview_margin);
list.setPaddingRelative(cardViewMargin/*start*/, cardViewMargin/*top*/, 0, list.getPaddingBottom());
}
return view;
}

View File

@ -20,7 +20,6 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="16dp"
android:background="@color/colorPrimary"
android:gravity="center"
android:textSize="@dimen/text_size_display_3"
@ -30,15 +29,14 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginTop="8dp"/>
android:layout_marginTop="@dimen/laps_container_margin_top"/>
</LinearLayout>
<!-- TODO: dimen resource for height -->
<android.support.v7.widget.GridLayout
android:id="@id/mini_fab_layout"
android:layout_width="match_parent"
android:layout_height="88dp"
android:layout_height="@dimen/fab_total_height"
android:layout_alignParentBottom="true"
app:columnCount="2">

View File

@ -14,7 +14,7 @@
android:id="@+id/chronometer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:padding="@dimen/chronometer_padding"
android:background="@color/colorPrimary"
android:gravity="center_horizontal"
android:textSize="@dimen/text_size_display_3"
@ -23,7 +23,7 @@
<include layout="@layout/fragment_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"/>
android:layout_marginTop="@dimen/laps_container_margin_top"/>
</LinearLayout>
@ -36,10 +36,9 @@
android:paddingStart="0dp"
android:paddingEnd="0dp"/>
<!-- TODO: dimen resource for height -->
<android.support.v7.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="88dp"
android:layout_height="@dimen/fab_total_height"
android:layout_gravity="bottom"
app:columnCount="2">

View File

@ -53,6 +53,10 @@
<dimen name="cardview_action_icon_margin">8dp</dimen>
<dimen name="cardview_action_icon_size">48dp</dimen>
<!-- StopwatchFragment -->
<dimen name="laps_container_margin_top">8dp</dimen>
<dimen name="chronometer_padding">16dp</dimen>
<dimen name="text_size_body_1">14sp</dimen>
<dimen name="text_size_body_2">14sp</dimen>
<dimen name="text_size_button">14sp</dimen>