以下内容转自:http://blog.csdn.net/kebi007/article/details/52820102
Cardview要引入support.v7兼容包,在nuget中可以进行引入,但编译仍可能出错,如“Download failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r32.zip and put it to the...”,解决方法参见遇到过的异常中的“引入兼容包报错”和android兼容包中的相关内容。
下面是布局文件内容:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#dedede"
android:padding="10dp">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="#00ffff"
android:id="@+id/card_view">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="科比詹姆斯JR斯密斯凯里欧文张林杜兰特库里英格拉姆格兰特希尔乔治德拉蒙德汤普森卡戴珊张林张木木易建联阿泰斯特"
android:gravity=""
android:textSize="20sp"
android:padding="10dp"
android:layout_margin="10dp"
android:textColor="#ffffff" />
</android.support.v7.widget.CardView>
<SeekBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/seekBar1" />
</LinearLayout>
以下是程序代码:
public class MainActivity : Activity, IOnSeekBarChangeListener
{
int count = 1;
private SeekBar seek;
private CardView cardview;
public void OnProgressChanged(SeekBar seekBar, int progress, bool fromUser)
{
if (fromUser)
{
cardview.Radius = progress;
cardview.CardElevation = progress;
}
}
public void OnStartTrackingTouch(SeekBar seekBar)
{
//throw new NotImplementedException(); 表示进度条刚开始拖动触发的操作
}
public void OnStopTrackingTouch(SeekBar seekBar)
{
//throw new NotImplementedException(); 停止拖动的时候触发的事件
}
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
seek = FindViewById<SeekBar>(Resource.Id.seekBar1);
cardview = FindViewById<CardView>(Resource.Id.card_view);
seek.SetOnSeekBarChangeListener(this);
}
}