0
레이아웃에 "lefttop"과 "topright"레이아웃이 내 조각에 0dp로 남아 있습니다.Android Layout_Weight 속성이 작동하지 않습니다.
상대적인 레이아웃의 너비에 실제 값 (id : 50dp)을 줄 때 그 안에있는 아이템이 실제로 나타나기 시작했는지 확인했습니다. 또한 "왼쪽 상단"및 "오른쪽 상단"의 부모 relativelayout이 " 실제로 실제로 내 cardview의 전체 너비와 높이를 차지합니다.
weightSum 및 layout_weight를 구현 한 방식에 문제가 있습니까? 나는이 내 코드 사람들이
을 가지고 여러 가지 유사한 문제 보았다 :
<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:cardCornerRadius="4dp"
android:layout_margin="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum = "1.5">
<!--Top Left section (name and adress)-->
<RelativeLayout
android:id="@+id/lefttop"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight = "1"
android:background="@drawable/borderright">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="contact det"
android:gravity="center_vertical"
android:textColor="@android:color/black"
android:paddingLeft="5dp"
android:textSize="40dp"
android:layout_alignParentTop="true"/>
<TextView
android:id="@+id/txtName"
android:layout_width="wrap_content"
android:layout_height="10dp"
android:text="Name"
android:gravity="center_vertical"
android:textSize="10dp"
android:layout_below="@id/title"
android:layout_marginTop="10dp"
android:layout_marginLeft="0dp"
android:paddingLeft="15dp"/>
</RelativeLayout>
<!--top right section with type of job and company-->
<RelativeLayout
android:id="@+id/topright"
android:layout_toRightOf="@+id/lefttop"
android:layout_width="0dp"
android:layout_height="26dp"
android:layout_weight = "0.5"
android:background="@drawable/borderright">
<TextView
android:id="@+id/txtSurname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Surname"
android:gravity="center_vertical"
android:textSize="10dp"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
android:background="@drawable/borderdown"/>
<TextView
android:id="@+id/txtEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textSize="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
'layout_weight'는'LinearLayout' 내부의'View'에만 적용됩니다. 너의 것은 'RelativeLayout'에있다. –
그 트릭을 했어! 이상하지만 그것은 어떤 오류없이 컴파일. 신속한 답변 마이크 주셔서 감사합니다! –