用卡片视图设计?
Designing with card view?
你可以在下图中看到我必须在第一个卡片视图中放置一个图像视图的打击中心 partition.i 知道如果卡片视图有固定大小该怎么做但在这种情况下我应该换行它根据屏幕 size.what 我还在粘贴 below.i 已经尝试了很多方法,但不是那个图像在所有设备中都得到准确的位置..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4">
<ImageView
android:id="@+id/img_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile_thumb" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="1dp">
</android.support.v7.widget.CardView>
</LinearLayout>
任何帮助将不胜感激..
供参考...
这个布局会产生预期的效果! (您必须自己输入边距等)。
它使用CoordinatorLayout, which you can find out more about here
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="192dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="192dp"/>
</LinearLayout>
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@android:color/black"
android:layout_margin="16dp"
app:layout_anchor="@+id/image"
app:layout_anchorGravity="bottom|end"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@android:color/black"
android:layout_margin="16dp"
app:layout_anchor="@+id/card"
app:layout_anchorGravity="bottom|end"
/>
</android.support.design.widget.CoordinatorLayout>
这个呢...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="1dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile_thumb" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="@color/red_primary_color"></LinearLayout>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="right|bottom"
android:layout_marginBottom="25dp"
android:layout_marginRight="20dp"
android:src="@drawable/abc_ic_menu_cut_mtrl_alpha" />
</FrameLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="1dp">
</android.support.v7.widget.CardView>
</LinearLayout>
你可以在下图中看到我必须在第一个卡片视图中放置一个图像视图的打击中心 partition.i 知道如果卡片视图有固定大小该怎么做但在这种情况下我应该换行它根据屏幕 size.what 我还在粘贴 below.i 已经尝试了很多方法,但不是那个图像在所有设备中都得到准确的位置..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="4">
<ImageView
android:id="@+id/img_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile_thumb" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="1dp">
</android.support.v7.widget.CardView>
</LinearLayout>
任何帮助将不胜感激..
供参考...
这个布局会产生预期的效果! (您必须自己输入边距等)。
它使用CoordinatorLayout, which you can find out more about here
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="192dp"
/>
<View
android:layout_width="match_parent"
android:layout_height="56dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="192dp"/>
</LinearLayout>
<View
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@android:color/black"
android:layout_margin="16dp"
app:layout_anchor="@+id/image"
app:layout_anchorGravity="bottom|end"
/>
<android.support.design.widget.FloatingActionButton
android:layout_width="48dp"
android:layout_height="48dp"
android:background="@android:color/black"
android:layout_margin="16dp"
app:layout_anchor="@+id/card"
app:layout_anchorGravity="bottom|end"
/>
</android.support.design.widget.CoordinatorLayout>
这个呢...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
card_view:cardCornerRadius="3dp"
card_view:cardElevation="1dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_profile_thumb" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="@color/red_primary_color"></LinearLayout>
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="right|bottom"
android:layout_marginBottom="25dp"
android:layout_marginRight="20dp"
android:src="@drawable/abc_ic_menu_cut_mtrl_alpha" />
</FrameLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
card_view:cardCornerRadius="1dp"
card_view:cardElevation="1dp">
</android.support.v7.widget.CardView>
</LinearLayout>