亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android控件CardView實現卡片效果

 更新時間:2020年02月04日 10:36:35   作者:cf8833  
這篇文章主要為大家詳細介紹了Android控件CardView實現卡片效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

這是android新推出的一個,讓卡片帶立體感的一個控件,就是一個卡牌,有點類似于布局那種的東西,里面可以添加控件內容

先看看運行的效果圖:

1.添加依賴

implementation 'com.android.support:cardview-v7:25.3.1'

2.主界面設置一些卡片的屬性:

package com.example.admin.ztest;
 
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
/*
app:cardBackgroundColor這是設置背景顏色 
app:cardCornerRadius這是設置圓角大小 
app:cardElevation這是設置z軸的陰影 
app:cardMaxElevation這是設置z軸的最大高度值 
app:cardUseCompatPadding是否使用CompatPadding 
app:cardPreventCornerOverlap是否使用PreventCornerOverlap 
app:contentPadding 設置內容的padding 
app:contentPaddingLeft 設置內容的左padding 
app:contentPaddingTop 設置內容的上padding 
app:contentPaddingRight 設置內容的右padding 
app:contentPaddingBottom 設置內容的底padding
 */
 
public class MainActivity extends AppCompatActivity {
  CardView cardView;
 
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_first);
    cardView = (CardView) findViewById(R.id.cardView);
    cardView.setRadius(8);//設置圖片圓角的半徑大小
    cardView.setCardElevation(8);//設置陰影部分大小
    cardView.setContentPadding(5, 5, 5, 5);//設置圖片距離陰影大小
  }
}

布局頁面:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/cardView"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_margin="10dp"
  app:cardCornerRadius="8dp">
 
 
  <LinearLayout
    android:layout_width="600pt"
    android:layout_height="100pt"
    android:background="@drawable/bg_battery_detail"
    android:orientation="vertical">
 
    <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginLeft="5dp"
      android:layout_marginRight="5dp"
      android:layout_marginTop="5dp"
      android:background="#184467">
 
      <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="horizontal">
 
        <TextView
          android:id="@+id/tvBatteryNo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:text="電池編號"
          android:textColor="@color/color_z2"
          android:textSize="20sp" />
 
        <TextView
          android:id="@+id/tvBatterySlotNo"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerVertical="true"
          android:layout_marginLeft="15pt"
          android:text="@string/app_name"
          android:textColor="@color/white"
          android:textSize="20sp" />
      </LinearLayout>
 
      <ImageView
        android:id="@+id/ivCloseDialog"
        android:layout_width="39pt"
        android:layout_height="39pt"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="8pt"
        android:padding="7pt"
        android:src="@mipmap/popup_del" />
 
    </RelativeLayout>
 
 
  </LinearLayout>
 
 
</android.support.v7.widget.CardView>

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • Android手勢密碼view學習筆記(一)

    Android手勢密碼view學習筆記(一)

    這篇文章主要為大家詳細介紹了Android手勢密碼view的學習筆記,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-03-03
  • Android實現ViewPage輪播圖效果

    Android實現ViewPage輪播圖效果

    這篇文章主要為大家詳細介紹了Android實現ViewPage輪播圖效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • Android編程獲取包名,版本信息及VersionName名稱的方法

    Android編程獲取包名,版本信息及VersionName名稱的方法

    這篇文章主要介紹了Android編程獲取包名,版本信息及VersionName名稱的方法,涉及Android包及版本相關操作函數使用技巧,需要的朋友可以參考下
    2016-10-10
  • Android獲取網絡連接狀態(tài)新方法整理

    Android獲取網絡連接狀態(tài)新方法整理

    這篇文章主要給大家介紹了關于Android獲取網絡連接狀態(tài)新方法的相關資料,在開發(fā)安卓移動端時幾乎每一個app都需要連接網絡,因此對設備的網絡狀態(tài)檢測是很有必要的,需要的朋友可以參考下
    2023-11-11
  • Android實現閱讀APP平移翻頁效果

    Android實現閱讀APP平移翻頁效果

    這篇文章主要介紹了Android實現閱讀APP平移翻頁效果的具體方法,模仿多看閱讀平移翻頁,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-03-03
  • 分享Android 藍牙4.0(ble)開發(fā)的解決方案

    分享Android 藍牙4.0(ble)開發(fā)的解決方案

    這篇文章主要為大家分享了Android 藍牙4.0(ble)開發(fā)的解決方案,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-03-03
  • android彈出activity設置大小的方法

    android彈出activity設置大小的方法

    本篇文章介紹了android彈出activity設置大小的方法,需要的朋友可以參考一下
    2013-06-06
  • Flutter組件狀態(tài)管理的3種方法

    Flutter組件狀態(tài)管理的3種方法

    這篇文章主要為大家詳細介紹了Flutter組件狀態(tài)管理的3種方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • Android Studio 3.5版本JNI生成SO文件詳解

    Android Studio 3.5版本JNI生成SO文件詳解

    這篇文章主要介紹了Android Studio 3.5版本JNI生成SO文件詳解,想了解JNI的同學,可以參考下
    2021-04-04
  • Android實現CoverFlow效果控件的實例代碼

    Android實現CoverFlow效果控件的實例代碼

    這篇文章主要介紹了Android實現CoverFlow效果控件的實例代碼,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05

最新評論