SupportLeanbackShowcase: get rid of card view background overdraw

Change-Id: I3a46d34df265eda2cf38bfca80d3786aa5a8a23b
This commit is contained in:
Dake Gu
2015-10-08 11:42:49 -07:00
parent 052b1d4aeb
commit 2157e7f4ec
5 changed files with 66 additions and 52 deletions

View File

@@ -30,7 +30,7 @@ import android.widget.TextView;
public class CharacterCardView extends BaseCardView {
public CharacterCardView(Context context) {
super(context);
super(context, null, R.style.CharacterCardStyle);
LayoutInflater.from(getContext()).inflate(R.layout.character_card, this);
setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
@@ -47,7 +47,6 @@ public class CharacterCardView extends BaseCardView {
}
});
setFocusable(true);
setBackground(null);
}
public void updateUi(Card card) {

View File

@@ -29,7 +29,7 @@ import android.widget.TextView;
public class TextCardView extends BaseCardView {
public TextCardView(Context context) {
super(context);
super(context, null, R.style.TextCardStyle);
LayoutInflater.from(getContext()).inflate(R.layout.text_icon_card, this);
setFocusable(true);
}

View File

@@ -39,9 +39,9 @@ public class SideInfoCardPresenter extends AbstractCardPresenter<BaseCardView> {
@Override
protected BaseCardView onCreateView() {
final BaseCardView cardView = new BaseCardView(getContext());
final BaseCardView cardView = new BaseCardView(getContext(), null,
R.style.SideInfoCardStyle);
cardView.setFocusable(true);
cardView.setCardType(BaseCardView.CARD_TYPE_MAIN_ONLY);
cardView.addView(LayoutInflater.from(getContext()).inflate(R.layout.side_info_card, null));
return cardView;
}

View File

@@ -14,55 +14,51 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/default_card_footer_background_color">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lb="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/main_image"
android:layout_width="144dp"
android:layout_height="144dp"
lb:layout_viewType="main"
/>
<LinearLayout
android:id="@+id/container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:id="@+id/info"
android:layout_width="144dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="11dp"
android:paddingRight="11dp"
android:paddingTop="7dp"
android:background="@color/default_card_footer_background_color">
<ImageView
android:id="@+id/main_image"
android:layout_width="144dp"
android:layout_height="144dp"
lb:layout_viewType="main"
/>
<TextView
android:id="@+id/primary_text"
style="@style/Widget.Leanback.ImageCardView.TitleStyle"
android:fontFamily="sans-serif-condensed"
android:maxLines="2"
android:textSize="16sp"/>
<LinearLayout
android:id="@+id/info"
android:layout_width="144dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="11dp"
android:paddingRight="11dp"
android:paddingTop="7dp">
<TextView
android:id="@+id/secondary_text"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:textColor="#EEEEEE"/>
<TextView
android:id="@+id/primary_text"
style="@style/Widget.Leanback.ImageCardView.TitleStyle"
android:fontFamily="sans-serif-condensed"
android:maxLines="2"
android:textSize="16sp"/>
<TextView
android:id="@+id/secondary_text"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="4dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="1"
android:textColor="#EEEEEE"/>
<TextView
android:id="@+id/extra_text"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="6dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="5"/>
</LinearLayout>
<TextView
android:id="@+id/extra_text"
style="@style/Widget.Leanback.ImageCardView.ContentStyle"
android:layout_marginTop="6dp"
android:fontFamily="sans-serif-condensed"
android:maxLines="5"/>
</LinearLayout>
</FrameLayout>
</LinearLayout>

View File

@@ -54,6 +54,7 @@
<style name="MovieCardSimpleStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewType">Title</item>
<item name="lbImageCardViewImageStyle">@style/MovieCardImageStyle</item>
<item name="cardBackground">@null</item>
</style>
<style name="MovieCardCompleteStyle" parent="MovieCardSimpleStyle">
@@ -75,6 +76,23 @@
<style name="SquareBigCard" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewImageStyle">@style/SquareBigCardImageStyle</item>
<item name="cardBackground">@null</item>
</style>
<!-- SideInfo. used in cards example -->
<style name="SideInfoCardStyle" parent="Widget.Leanback.BaseCardViewStyle">
<item name="cardType">mainOnly</item>
<item name="cardBackground">@null</item>
</style>
<!-- TextCardView. used in cards example -->
<style name="TextCardStyle" parent="Widget.Leanback.BaseCardViewStyle">
<item name="cardBackground">@null</item>
</style>
<!-- CharacterCardView. used in details example -->
<style name="CharacterCardStyle" parent="Widget.Leanback.BaseCardViewStyle">
<item name="cardBackground">@null</item>
</style>
<!-- Grid card style. Used by Grid example. -->
@@ -85,6 +103,7 @@
<style name="GridCardStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="lbImageCardViewImageStyle">@style/GridCardImageStyle</item>
<item name="cardBackground">@null</item>
</style>
<!-- A default card style. Used in cards example. -->
@@ -94,6 +113,7 @@
</style>
<style name="DefaultCardStyle" parent="Widget.Leanback.ImageCardViewStyle">
<item name="cardBackground">@null</item>
<item name="lbImageCardViewImageStyle">@style/DefaultCardImageStyle</item>
</style>
@@ -155,7 +175,6 @@
</style>
<style name="IconCardStyle" parent="DefaultCardStyle">
<item name="cardBackground">@null</item>
<item name="android:layout_width">96dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="lbImageCardViewTitleStyle">@style/IconCardTitleStyle</item>