0
내 안드로이드 응용 프로그램에서 나는 CardViews에 표시하려는 부분입니다. 이 두 가지 CardView는 전체 화면 영역을 채 웁니다. cardview 요소 내부에 표시되는 이미지는 매우 큰 이미지이며 카드 뷰 내부에 표시되도록 축소해야합니다. 다음 코드로 화면의 전체 영역을 채울 수없고 cardview를 클릭 할 수있게합니다.필 카드보기 화면 영역 내
<FrameLayout 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"
tools:context="com.myFirstApp.app1.cardviewFragment">
<!-- TODO: Update blank fragment layout -->
<!--<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal"
android:background="@android:color/holo_blue_bright" ></android.support.v7.widget.RecyclerView>-->
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp" android:background="@color/colorAccent">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="8dp"
android:layout_marginBottom="16dp">
<LinearLayout android:orientation="vertical"
android:id="@+id/display_card_view_linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/display_name1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="@string/app_name"
android:textColor="#ffffff"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:background="#1976D2"/>
<ImageView
android:id="@+id/display_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_settings"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/display_information1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:text="Card View Footer"
android:textColor="#ffffff"
android:layout_below="@+id/display_image1"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:background="#1976D2"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="8dp"
android:layout_marginBottom="16dp">
<LinearLayout android:orientation="vertical"
android:id="@+id/display_card_view_linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/display_name2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="13sp"
android:text="@string/app_name"
android:textColor="#ffffff"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:background="#1976D2"/>
<ImageView
android:id="@+id/display_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_settings"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/display_information2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="13sp"
android:text="Card View Footer"
android:textColor="#ffffff"
android:layout_below="@+id/display_image2"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:background="#1976D2"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</FrameLayout>
어떻게 CardView가 전체 영역을 채우고 클릭 할 수있게 할 수 있습니까? 사전에
감사합니다,
IamHuM
답변을 확장하여 이것이 왜 효과가 있는지에 대한 설명을 포함 시키십시오. – sds
이 작품은 당신을 위해 작동하지만 내 응용 프로그램 중 하나에서 작동하도록 설정 작업 레이아웃에서 코드 [GitHub code] (https://github.com/brunomassa/LuxVilla)를 사용할 수 있습니다. 전폭 카드 뷰. –
괜찮므로 답장에 의견을 병합하십시오 ("편집"을 클릭하십시오). – sds