cardview使用笔记
来源:互联网 发布:网络校时原理 编辑:程序博客网 时间:2024/05/12 15:46
首先导入
…\android-sdk\extras\android\support\v7\cardview
lib项目
xml
<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="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <android.support.v7.widget.CardView xmlns:cardview="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/activity_horizontal_margin" android:layout_marginRight="@dimen/activity_horizontal_margin" android:layout_marginTop="5dp" android:layout_marginBottom="5dp" cardview:cardCornerRadius="10dp" cardview:cardBackgroundColor="@android:color/white" cardview:cardElevation="24dp"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin" > <ImageView android:id="@+id/img" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" android:layout_centerHorizontal="true" android:scaleType="fitCenter" /> <TextView android:id="@+id/text_desc" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/img" android:layout_centerHorizontal="true" android:text="This is a card view" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" /> </RelativeLayout> </android.support.v7.widget.CardView> <SeekBar android:layout_below="@+id/card_view" android:id="@+id/seek1" android:layout_marginTop="10dp" android:layout_width="150dp" android:layout_height="30dp" /> <SeekBar android:layout_below="@+id/seek1" android:id="@+id/seek2" android:layout_marginTop="10dp" android:layout_width="150dp" android:layout_height="30dp" /></RelativeLayout>
java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); cardView = (CardView) findViewById(R.id.card_view); SeekBar seek1 = (SeekBar) findViewById(R.id.seek1); SeekBar seek2 = (SeekBar) findViewById(R.id.seek2); seek1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if (b) { cardView.setCardElevation(i);//阴影shadow } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); seek2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { if (b) { cardView.setRadius(i);//圆角大小设置 } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); }
0 0
- cardview使用笔记
- 【安卓笔记】CardView+RecyclerView使用示例
- 安卓笔记:CardView的使用
- CardView使用
- cardView使用
- CardView使用
- CardView使用
- Android 5.0 CardView 笔记
- CardView学习笔记
- CardView初级使用
- CardView和SeekBar使用
- Android开发--CardView使用
- RecyclerView CardView使用解析
- Android开发--CardView使用
- CardView,RecyclerView的使用
- RecyclerView结合CardView使用
- CardView使用要点
- CardView的使用
- Using Arel to Compose SQL Queries
- ELKStack编码插件(Codec)
- 数据库性能优化主要包括哪些方面?
- Android Studio解决unspecified on project app resolves to an APK archive which is not supported
- 一个神经网络模式识别的例子------螃蟹识别
- cardview使用笔记
- 第一章 基本语法-2运算符
- 听说网易用户信息泄露了?
- 【算法】数组中的逆序对的总数
- 2015网页导航设计趋势&案例大搜罗
- Spark学习笔记之-Spark 命令及程序入口
- SVN与CVS比较
- 禁止Apache显示目录索引
- 测试我的第一篇博客