cardview属性收集

  • <h1>GuideView</h1>
  • 本系统能够快速的为一个Activity里的任何一个View控件创建一个卡片式的布局。</p>
  • <h3>工作原理</h3>
cardview.png
  • <h3>usage</h3>
    <android.support.v7.widget.CardView
    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="wrap_content"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginTop="6dp"
    android:foreground="?attr/selectableItemBackground"
    app:cardBackgroundColor="@android:color/white"
    app:cardPreventCornerOverlap="false"
    app:cardUseCompatPadding="true">
    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp">

     <TextView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="热门回答"
         android:textColor="#9c9c9c"
         android:textSize="13sp"/>
    
     <TextView
         android:id="@+id/tv_title"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginBottom="8dp"
         android:layout_marginTop="8dp"
         android:text="热门回答"
         android:textColor="@android:color/black"
         android:textSize="16sp"/>
    
     <TextView
         android:id="@+id/tv_content"
         android:text="热门回答"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"/>
            </LinearLayout>
    </android.support.v7.widget.CardView>
    
  • 新闻条目.png
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.CardView
    android:id="@+id/home_item_root_view"
    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"
    app:cardCornerRadius="2dp"
    app:cardElevation="0dp">
    
     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:background="?android:attr/itemBackground"
                  android:orientation="vertical">
    
      <ImageView
          android:id="@+id/iv_news_summary_photo"
          android:layout_width="72dp"
          android:layout_height="72dp"
          android:layout_margin="4dp"
          android:scaleType="centerCrop"
          android:transitionName="photos"
          tools:src="@drawable/ic_header"/>
    
      <TextView
          android:id="@+id/tv_news_summary_title"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignTop="@+id/iv_news_summary_photo"
          android:layout_toRightOf="@+id/iv_news_summary_photo"
          android:gravity="center_vertical"
          android:singleLine="true"
          android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
          android:textColor="?android:attr/textColorPrimary"
          tools:text="中石油:美国油价便宜因不含税"/>
    
      <TextView
          android:id="@+id/tv_news_summary_digest"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignBottom="@+id/iv_news_summary_photo"
          android:layout_alignLeft="@+id/tv_news_summary_title"
          android:layout_below="@+id/tv_news_summary_title"
          android:layout_marginTop="2dp"
          android:ellipsize="end"
          android:lines="2"
          android:textAppearance="@style/TextAppearance.AppCompat.Small"
          android:textColor="?android:attr/textColorPrimary"
          tools:text="中国油价的48%交税了,美国价税分离,价是价,税是税。"/>
    
      <TextView
          android:id="@+id/tv_news_summary_ptime"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBottom="@+id/iv_news_summary_photo"
          android:layout_alignParentRight="true"
          android:layout_marginRight="8dp"
          android:textAppearance="@style/TextAppearance.AppCompat.Small"
          android:textColor="?android:attr/textColorSecondary"
          android:textSize="12sp"
          tools:text="2016-02-19 08:09:19"/>
    
    </RelativeLayout>
    </android.support.v7.widget.CardView>
    
  • QQ截图20160725170539.png

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.CardView
    android:id="@+id/home_item_root_view"
    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="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginLeft="2dp"
    android:layout_marginRight="2dp"
    app:cardCornerRadius="2dp"
    app:cardElevation="0dp">

     <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="?android:attr/itemBackground"
      android:orientation="vertical">
    
      <ImageView
          android:id="@+id/iv_photo_summary"
          android:layout_width="200dp"
          android:layout_height="200dp"
          android:layout_marginLeft="2dp"
          android:layout_marginRight="2dp"
          android:layout_marginTop="2dp"
          android:scaleType="centerCrop"
          android:transitionName="photos"
          tools:src="@drawable/ic_header"/>
    
      <TextView
          android:id="@+id/tv_photo_summary"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="center"
          android:padding="8dp"
          android:textAppearance="@style/TextAppearance.AppCompat.Caption"
          android:textColor="?android:attr/textColorSecondary"
          tools:text="近日,在网上爆红的少女组合Sunshine通过官方微博发布一组唯美风格写真。"/>
    
    </LinearLayout>
    
    </android.support.v7.widget.CardView>
    
QQ截图20160729111406.png
  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical">

  <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:background="@drawable/item_selector"
    android:orientation="vertical"
    android:paddingBottom="8dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="8dp">

    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="4dp"
        android:text="Title"
        android:textColor="#333333"
        android:textSize="16sp"
        android:textStyle="bold"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:baselineAligned="true"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/image"
            android:layout_width="100dp"
            android:layout_height="60dp"
            android:contentDescription="@string/app_name"
            android:src="@drawable/app_icon"
            android:visibility="visible"/>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginEnd="8dp"
            android:layout_marginStart="8dp">

            <TextView
                android:id="@+id/content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:ellipsize="end"
                android:gravity="top"
                android:maxLines="2"
                android:text="content"
                android:textColor="#999999"
                android:textSize="13sp"/>

            <TextView
                android:id="@+id/date"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentRight="true"
                android:singleLine="true"
                android:text="date"
                android:textSize="12sp"/>
        </RelativeLayout>
    </LinearLayout>

  </LinearLayout>
  </LinearLayout>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容