내 FrameLayout
의 가로 세로 비율을 프로그래밍 방식으로 PercentRelativeLayout
에 설정하고 싶습니다.프로그래밍 방식으로 PercentageRelativeLayout의 가로 세로 비율을 설정하십시오.
<android.support.percent.PercentRelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#000"
xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
app:layout_widthPercent="100%"
app:layout_aspectRatio="178%" //aspect ratio
android:orientation="vertical"
android:id="@+id/liveTV_frame"
android:layout_marginBottom="50dp"
android:layout_centerInParent="true"
android:background="@android:color/background_dark"
android:keepScreenOn="true">
</FrameLayout>
</android.support.percent.PercentRelativeLayout>
하지만 프로그래밍 방식으로 설정해야합니다
이미xml
에서 재판을
, 그것은 일하고있어.
어떻게하면됩니까? 분수를 사용하지 않고 그냥 내 대답을 정교하게 @azizbekian 대답에서
[this] (http://stackoverflow.com/questions/32292656/percentrelativelayout-how-to-set-the-height-programatically)이 솔루션을 얻는 데 도움이 될 수 있습니다! –
@ 조이 하드, 당신의 cmts을 주셔서 감사합니다. 하지만 가로 세로 비율을 높이로 설정해야합니다. –
아무 이유없이 사람들이 왜이 질문에 대해 하향 파문을하는지. –