最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android控件CardView實現(xiàn)卡片布局

 更新時間:2018年10月23日 15:29:19   作者:簡單不一定不好  
這篇文章主要為大家詳細(xì)介紹了Android控件CardView實現(xiàn)卡片布局,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

CardView介紹

CardView是Android 5.0系統(tǒng)引入的控件,相當(dāng)于FragmentLayout布局控件然后添加圓角及陰影的效果;CardView被包裝為一種布局,并且經(jīng)常在ListView和RecyclerView的Item布局中,作為一種容器使用。CardView應(yīng)該被使用在顯示層次性的內(nèi)容時;在顯示列表或網(wǎng)格時更應(yīng)該被選擇,因為這些邊緣可以使得用戶更容易去區(qū)分這些內(nèi)容。

使用

先看效果

首先在build.gradle文件添加依賴庫

dependencies {
 compile fileTree(include: ['*.jar'], dir: 'libs')
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:24.2.0'
 compile 'com.android.support:cardview-v7:24.2.0'
}

布局文件main.html文件下

<?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="match_parent">

 <android.support.v7.widget.CardView
 android:id="@+id/cardView"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_margin="10dp">

 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="100dp">

  <ImageView
  android:layout_width="150dp"
  android:layout_height="match_parent"
  android:layout_margin="5dp"
  android:scaleType="centerCrop"
  android:src="@drawable/sng" />

  <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical">

  <TextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:padding="5dp"
   android:text="棒冰行動"
   android:textSize="18sp"
   android:textStyle="bold" />

  <TextView
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:padding="5dp"
   android:text="棒冰行動,公益?zhèn)鞑ピO(shè)計夏令營" />
  </LinearLayout>
 </LinearLayout>
 </android.support.v7.widget.CardView>

</LinearLayout>

在MainActivity.java下文件

public class MainActivity extends AppCompatActivity {

 private CardView cardView;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);

 cardView = (CardView)findViewById(R.id.cardView);

 cardView.setRadius(8);//設(shè)置圖片圓角的半徑大小

 cardView.setCardElevation(8);//設(shè)置陰影部分大小

 cardView.setContentPadding(5,5,5,5);//設(shè)置圖片距離陰影大小
 }
}

好,已結(jié)束CardView難度不大,當(dāng)是實用性及及效果是非常棒的,值得你擁有!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android實現(xiàn)通用篩選欄

    Android實現(xiàn)通用篩選欄

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)通用篩選欄,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-10-10
  • Android使用DocumentFile讀寫外置存儲的問題

    Android使用DocumentFile讀寫外置存儲的問題

    大家好,本篇文章主要講的是Android使用DocumentFile讀寫外置存儲的問題,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下
    2021-12-12
  • HttpClient通過Post上傳文件的實例代碼

    HttpClient通過Post上傳文件的實例代碼

    這篇文章主要介紹了HttpClient通過Post上傳文件的實例代碼的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下
    2016-08-08
  • Android中Textview和圖片同行顯示(文字超出用省略號,圖片自動靠右邊)

    Android中Textview和圖片同行顯示(文字超出用省略號,圖片自動靠右邊)

    Android中Textview和圖片同行顯示,文字超出用省略號顯示,圖片自動靠右邊??吹竭@個問題本來認(rèn)為是一個很正常的需求,看起來很簡單,但是做起來卻遇到了很蛋疼的問題,怎么搞的都不行,堵了很長時間,下面說一下解決的方案,希望遇到這樣問題的朋友可以使用。
    2016-12-12
  • Android實現(xiàn)類似3D Touch菜單功能

    Android實現(xiàn)類似3D Touch菜單功能

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)類似3D Touch菜單功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • Android Studio實現(xiàn)帶邊框的圓形頭像

    Android Studio實現(xiàn)帶邊框的圓形頭像

    這篇文章主要為大家詳細(xì)介紹了Android Studio實現(xiàn)帶邊框的圓形頭像,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • 如何給Flutter界面切換實現(xiàn)點特效

    如何給Flutter界面切換實現(xiàn)點特效

    這篇文章主要給大家介紹了關(guān)于如何給Flutter界面切換實現(xiàn)點特效的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Flutter具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • Flutter實現(xiàn)網(wǎng)絡(luò)請求的方法示例

    Flutter實現(xiàn)網(wǎng)絡(luò)請求的方法示例

    這篇文章主要介紹了Flutter實現(xiàn)網(wǎng)絡(luò)請求的方法示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-03-03
  • Android自定義view實現(xiàn)輸入控件

    Android自定義view實現(xiàn)輸入控件

    這篇文章主要為大家詳細(xì)介紹了Android自定義view實現(xiàn)輸入控件,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android實現(xiàn)用戶登錄記住密碼功能

    Android實現(xiàn)用戶登錄記住密碼功能

    這篇文章主要為大家詳細(xì)介紹了Android實現(xiàn)用戶登錄記住密碼功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-05-05

最新評論

沽源县| 徐闻县| 永寿县| 恩平市| 东乌| 增城市| 淮北市| 南乐县| 蓝山县| 天全县| 桂东县| 菏泽市| 沁源县| 阿勒泰市| 石河子市| 甘泉县| 两当县| 肃宁县| 衡阳市| 阿鲁科尔沁旗| 长垣县| 大兴区| 勐海县| 惠安县| 洪洞县| 平谷区| 慈溪市| 大渡口区| 黑河市| 凤阳县| 景德镇市| 久治县| 旅游| 镇原县| 榆树市| 博白县| 同仁县| 福清市| 铜山县| 博兴县| 成武县|