am 7114577a: [SetupWizard] Add attributes for illustration size
* commit '7114577a094593dbf55b625146b3809800697030': [SetupWizard] Add attributes for illustration size
This commit is contained in:
commit
aa7fad30f4
|
@ -16,7 +16,6 @@
|
|||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -29,7 +28,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/suw_layout_background"
|
||||
android:elevation="@dimen/suw_title_area_elevation"
|
||||
app:suwAspectRatio="2.22"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/suw_card_port_margin_sides"
|
||||
android:paddingRight="@dimen/suw_card_port_margin_sides">
|
||||
|
|
|
@ -39,13 +39,12 @@
|
|||
style="@style/SuwCardTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
|
||||
android:layout_weight="6" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_card_land_margin_top"
|
||||
android:layout_weight="8"
|
||||
android:background="?attr/suwCardBackground"
|
||||
android:elevation="@dimen/suw_card_elevation"
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/suw_card_port_margin_sides"
|
||||
android:paddingRight="@dimen/suw_card_port_margin_sides">
|
||||
|
|
|
@ -42,13 +42,12 @@
|
|||
style="@style/SuwCardTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
|
||||
android:layout_weight="6" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_card_land_margin_top"
|
||||
android:layout_weight="8"
|
||||
android:background="?attr/suwCardBackground"
|
||||
android:elevation="@dimen/suw_card_elevation"
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
header to the RecyclerView or avoid using this layout (e.g. use suw_no_scroll_template_short
|
||||
instead of suw_no_scroll_template) -->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -40,7 +39,6 @@
|
|||
android:background="@drawable/suw_layout_background"
|
||||
android:elevation="@dimen/suw_title_area_elevation"
|
||||
android:tag="stickyContainer"
|
||||
app:suwAspectRatio="2.22"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="@dimen/suw_card_port_margin_sides"
|
||||
android:paddingRight="@dimen/suw_card_port_margin_sides">
|
||||
|
|
|
@ -39,13 +39,12 @@
|
|||
style="@style/SuwCardTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/suw_tablet_illustration_height"
|
||||
android:layout_marginTop="@dimen/suw_card_land_header_text_margin_top"
|
||||
android:layout_weight="6" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/suw_card_land_margin_top"
|
||||
android:layout_weight="8"
|
||||
android:background="?attr/suwCardBackground"
|
||||
android:elevation="@dimen/suw_card_elevation"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -54,7 +53,6 @@
|
|||
android:background="@drawable/suw_layout_background"
|
||||
android:elevation="@dimen/suw_title_area_elevation"
|
||||
android:orientation="vertical"
|
||||
app:suwAspectRatio="2.22"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -23,4 +23,10 @@
|
|||
<dimen name="suw_card_title_padding_top">24dp</dimen>
|
||||
<dimen name="suw_card_title_padding_bottom">0dp</dimen>
|
||||
|
||||
<!-- Decor view (illustration or the header without illustration) -->
|
||||
<dimen name="suw_decor_padding_top">0dp</dimen>
|
||||
|
||||
<!-- Illustration -->
|
||||
<item name="suw_illustration_aspect_ratio" format="float" type="dimen">0</item>
|
||||
|
||||
</resources>
|
||||
|
|
26
library/main/res/values-sw600dp-land/dimens.xml
Normal file
26
library/main/res/values-sw600dp-land/dimens.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Decor view (illustration or the header without illustration) -->
|
||||
<dimen name="suw_decor_padding_top">128dp</dimen>
|
||||
|
||||
<!-- Illustration -->
|
||||
<item name="suw_illustration_aspect_ratio" format="float" type="dimen">0.0</item>
|
||||
|
||||
</resources>
|
26
library/main/res/values-sw600dp/dimens.xml
Normal file
26
library/main/res/values-sw600dp/dimens.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Decor view (illustration or the header without illustration) -->
|
||||
<dimen name="suw_decor_padding_top">256dp</dimen>
|
||||
|
||||
<!-- Illustration -->
|
||||
<item name="suw_illustration_aspect_ratio" format="float" type="dimen">0</item>
|
||||
|
||||
</resources>
|
|
@ -40,7 +40,9 @@
|
|||
<attr name="suwBackground" format="color|reference" />
|
||||
<attr name="suwBackgroundTile" format="color|reference" />
|
||||
<attr name="suwHeaderText" format="string" localization="suggested" />
|
||||
<attr name="suwDecorPaddingTop" format="dimension|reference" />
|
||||
<attr name="suwIllustration" format="color|reference" />
|
||||
<attr name="suwIllustrationAspectRatio" format="float|reference" />
|
||||
<attr name="suwIllustrationHorizontalTile" format="color|reference" />
|
||||
<attr name="suwIllustrationImage" format="color|reference" />
|
||||
</declare-styleable>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<!-- Card layout (for tablets) -->
|
||||
<dimen name="suw_card_corner_radius">2dp</dimen>
|
||||
<dimen name="suw_card_elevation">5dp</dimen>
|
||||
<dimen name="suw_card_land_margin_top">128dp</dimen>
|
||||
<dimen name="suw_card_land_header_text_margin_top">128dp</dimen>
|
||||
<dimen name="suw_card_port_margin_sides">56dp</dimen>
|
||||
|
||||
<dimen name="suw_card_title_padding_end">0dp</dimen>
|
||||
|
@ -42,6 +42,9 @@
|
|||
|
||||
<dimen name="suw_tablet_illustration_height">256dp</dimen>
|
||||
|
||||
<!-- Decor view (illustration or the header without illustration) -->
|
||||
<dimen name="suw_decor_padding_top">0dp</dimen>
|
||||
|
||||
<!-- Header layout (for phones) -->
|
||||
<dimen name="suw_title_area_elevation">3dp</dimen>
|
||||
|
||||
|
@ -52,6 +55,9 @@
|
|||
<!-- This is the extra spacing required to make the leading exactly 32sp -->
|
||||
<dimen name="suw_header_title_line_spacing_extra">3.67sp</dimen>
|
||||
|
||||
<!-- Illustration -->
|
||||
<item name="suw_illustration_aspect_ratio" format="float" type="dimen">2.22</item>
|
||||
|
||||
<!-- Navigation bar -->
|
||||
<dimen name="suw_navbar_button_drawable_padding">6dp</dimen>
|
||||
<dimen name="suw_navbar_button_padding_sides">10dp</dimen>
|
||||
|
|
|
@ -29,6 +29,7 @@ import android.os.Build.VERSION_CODES;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -117,6 +118,26 @@ public class SetupWizardLayout extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
// Set the top padding of the illustration
|
||||
int decorPaddingTop = a.getDimensionPixelSize(
|
||||
R.styleable.SuwSetupWizardLayout_suwDecorPaddingTop, -1);
|
||||
if (decorPaddingTop == -1) {
|
||||
decorPaddingTop = getResources().getDimensionPixelSize(R.dimen.suw_decor_padding_top);
|
||||
}
|
||||
setDecorPaddingTop(decorPaddingTop);
|
||||
|
||||
|
||||
// Set the illustration aspect ratio. See Illustration.setAspectRatio(float). This will
|
||||
// override suwIllustrationPaddingTop if its value is not 0.
|
||||
float illustrationAspectRatio = a.getFloat(
|
||||
R.styleable.SuwSetupWizardLayout_suwIllustrationAspectRatio, -1f);
|
||||
if (illustrationAspectRatio == -1f) {
|
||||
final TypedValue out = new TypedValue();
|
||||
getResources().getValue(R.dimen.suw_illustration_aspect_ratio, out, true);
|
||||
illustrationAspectRatio = out.getFloat();
|
||||
}
|
||||
setIllustrationAspectRatio(illustrationAspectRatio);
|
||||
|
||||
// Set the header text
|
||||
final CharSequence headerText =
|
||||
a.getText(R.styleable.SuwSetupWizardLayout_suwHeaderText);
|
||||
|
@ -258,6 +279,39 @@ public class SetupWizardLayout extends FrameLayout {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the aspect ratio of the illustration. This will be the space (padding top) reserved
|
||||
* above the header text. This will override the padding top of the illustration.
|
||||
*
|
||||
* @param aspectRatio The aspect ratio
|
||||
* @see com.android.setupwizardlib.view.Illustration#setAspectRatio(float)
|
||||
*/
|
||||
public void setIllustrationAspectRatio(float aspectRatio) {
|
||||
final View view = findViewById(R.id.suw_layout_decor);
|
||||
if (view instanceof Illustration) {
|
||||
final Illustration illustration = (Illustration) view;
|
||||
illustration.setAspectRatio(aspectRatio);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the top padding of the decor view. If the decor is an Illustration and the aspect ratio
|
||||
* is set, this value will be overridden.
|
||||
*
|
||||
* Note: Currently the default top padding for tablet landscape is 128dp, which is the offset
|
||||
* of the card from the top. This is likely to change in future versions so this value aligns
|
||||
* with the height of the illustration instead.
|
||||
*
|
||||
* @param paddingTop The top padding in pixels.
|
||||
*/
|
||||
public void setDecorPaddingTop(int paddingTop) {
|
||||
final View view = findViewById(R.id.suw_layout_decor);
|
||||
if (view != null) {
|
||||
view.setPadding(view.getPaddingLeft(), paddingTop, view.getPaddingRight(),
|
||||
view.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the background of the layout, which is expected to be able to extend infinitely. If it is
|
||||
* a bitmap tile and you want it to repeat, use {@link #setBackgroundTile(int)} instead.
|
||||
|
|
|
@ -112,6 +112,20 @@ public class Illustration extends FrameLayout {
|
|||
requestLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the aspect ratio reserved for the illustration. This overrides the top padding of the
|
||||
* view according to the width of this view and the aspect ratio. Children views will start
|
||||
* being laid out below this aspect ratio.
|
||||
*
|
||||
* @param aspectRatio A float value specifying the aspect ratio (= width / height). 0 to not
|
||||
* override the top padding.
|
||||
*/
|
||||
public void setAspectRatio(float aspectRatio) {
|
||||
mAspectRatio = aspectRatio;
|
||||
invalidate();
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setForeground(Drawable d) {
|
||||
|
|
Loading…
Reference in a new issue