在哪个网站做一照一码,十大咨询公司排行榜,山西seo优化公司,中国建筑英才网官网CardView介绍 CardView是Android 5.0系统引入的控件#xff0c;相当于FragmentLayout布局控件然后添加圆角及阴影的效果#xff1b;CardView被包装为一种布局#xff0c;并且经常在ListView和RecyclerView的Item布局中#xff0c;作为一种容器使用。CardView应该被使用在显…CardView介绍 CardView是Android 5.0系统引入的控件相当于FragmentLayout布局控件然后添加圆角及阴影的效果CardView被包装为一种布局并且经常在ListView和RecyclerView的Item布局中作为一种容器使用。CardView应该被使用在显示层次性的内容时在显示列表或网格时更应该被选择因为这些边缘可以使得用户更容易去区分这些内容。 使用 先看效果 首先在build.gradle文件添加依赖库 dependencies {compile fileTree(include: [*.jar], dir: libs)testCompile junit:junit:4.12compile com.android.support:appcompat-v7:24.2.0compile com.android.support:cardview-v7:24.2.0
} 布局文件main.html文件下 ?xml version1.0 encodingutf-8?
LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid.support.v7.widget.CardViewandroid:idid/cardViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_margin10dpLinearLayoutandroid:layout_widthmatch_parentandroid:layout_height100dpImageViewandroid:layout_width150dpandroid:layout_heightmatch_parentandroid:layout_margin5dpandroid:scaleTypecenterCropandroid:srcdrawable/sng /LinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalTextViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:padding5dpandroid:text棒冰行动android:textSize18spandroid:textStylebold /TextViewandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:padding5dpandroid:text棒冰行动公益传播设计夏令营 //LinearLayout/LinearLayout/android.support.v7.widget.CardView/LinearLayout 在MainActivity.Java下文件 public class MainActivity extends AppCompatActivity {private CardView cardView;Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);cardView (CardView)findViewById(R.id.cardView);cardView.setRadius(8);//设置图片圆角的半径大小
cardView.setCardElevation(8);//设置阴影部分大小
cardView.setContentPadding(5,5,5,5);//设置图片距离阴影大小}
}