auick action widget (size/bg fixed)
This commit is contained in:
parent
def51a0dc2
commit
46a2fcce09
4 changed files with 60 additions and 34 deletions
9
OsmAnd/res/drawable/quick_action_background.xml
Normal file
9
OsmAnd/res/drawable/quick_action_background.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<gradient
|
||||
android:startColor="@color/popup_bg_color"
|
||||
android:endColor="@color/color_transparent" android:angle="-90"/>
|
||||
|
||||
</shape>
|
|
@ -1,48 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/bg_card_light"
|
||||
android:orientation="vertical"
|
||||
android:clickable="true">
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp" />
|
||||
android:background="@drawable/quick_action_background">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/quick_action_controls_background"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:background="@drawable/bg_card_light"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnPrev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dots"
|
||||
android:id="@+id/controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal" />
|
||||
android:layout_height="48dp"
|
||||
android:background="@drawable/quick_action_controls_background"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
<ImageButton
|
||||
android:id="@+id/btnPrev"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dots"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btnNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?android:selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
|
@ -7,4 +7,7 @@
|
|||
<dimen name="first_usage_title_margin_bottom">56dp</dimen>
|
||||
<dimen name="first_usage_title_text_size">52sp</dimen>
|
||||
<dimen name="first_usage_subtitle_text_size">18sp</dimen>
|
||||
|
||||
<dimen name="quick_action_widget_height_big">200dp</dimen>
|
||||
<dimen name="quick_action_widget_height_small">100dp</dimen>
|
||||
</resources>
|
|
@ -69,6 +69,12 @@ public class QuickActionsWidget extends LinearLayout {
|
|||
viewPager = (ViewPager) findViewById(R.id.viewPager);
|
||||
viewPager.setAdapter(new ViewsPagerAdapter());
|
||||
|
||||
viewPager.getLayoutParams().height = actions.size() > ELEMENT_PER_PAGE / 2
|
||||
? (int) getResources().getDimension(R.dimen.quick_action_widget_height_big)
|
||||
: (int) getResources().getDimension(R.dimen.quick_action_widget_height_small);
|
||||
|
||||
viewPager.requestLayout();
|
||||
|
||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
|
Loading…
Reference in a new issue