1
모든 안드로이드 장치에 대한 디자인을 만들고 싶습니다. 이를 위해 LinearLayouts에 높이를 사용하고 백분율 솔루션을 사용합니다.LinearLayout은 weight 속성 (높이)을 사용하여 TextView 텍스트를 자릅니다.
화면이 여러 섹션 (가중치가있는 선형 평면)으로 나뉩니다. 이 LinearLayouts에는 TextView와 같은 요소가 있습니다.
그러나 높이가있는 LinearLayout을 사용하면 아래쪽의 TextView가 잘릴 수 있습니다.
가중치에 따라 동적으로 텍스트 크기를 변경하려면 어떻게해야합니까?
코드 :
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="0.04"
android:weightSum="1">
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="0.05799" />
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="0.86951">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:text="Benachrichtigungen"
android:textStyle="bold"
android:textSize="20sp"
android:id="@+id/header"/>
</LinearLayout>
<LinearLayout
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="0.0722106" />
</LinearLayout>
이미지 :
스크린 샷과 현재 xml이 답을 빨리 찾는 데 도움이 될 수 있습니다. –
내 질문을 업데이트했습니다. 귀하의 제안에 감사드립니다. :) –
신장을 제약해야합니까? 그렇지 않으면 outter LinearLayout 높이를 wrap_content로 설정하십시오. –