RelativeLayout
에서 5 개의보기 (위, 아래, 왼쪽, 오른쪽, 가운데)로 다음 결과를 얻은 다음 카메라 미리보기를 배치합니다. 나는 또한 원하는 무엇안드로이드 경계선 주위의보기가 작동하지 않습니다.
중심보기 주위에 테두리를 그릴 것입니다. 나는 그것을 위해 shape drawable을 사용했다. 그러나 그것은 작동하지 않았다. 테두리는 중심을 제외한 상대적인 레이아웃의 모든 뷰에 적용됩니다.
어떻게 테두리를 그릴 수 있습니까? 여기
레이아웃입니다 :<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/camera_preview"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_weight="1" >
<View
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentTop="true"
android:layout_gravity="center"
android:background="#80000000" />
<View
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="180dp"
android:layout_alignParentBottom="true"
android:layout_gravity="center"
android:background="#80000000" />
<View
android:id="@+id/left"
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_above="@id/bottom"
android:layout_alignParentLeft="true"
android:layout_below="@id/top"
android:layout_gravity="center"
android:background="#80000000" />
<View
android:id="@+id/right"
android:layout_width="100dp"
android:layout_height="match_parent"
android:layout_above="@id/bottom"
android:layout_alignParentRight="true"
android:layout_below="@id/top"
android:layout_gravity="center"
android:background="#80000000" />
<View
android:id="@+id/center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/bottom"
android:layout_below="@id/top"
android:layout_gravity="center"
android:layout_margin="25dp"
android:layout_toLeftOf="@+id/left"
android:layout_toRightOf="@id/right"
android:background="@drawable/border_red" />
</RelativeLayout>
<Button
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Capture" />
</LinearLayout>
여기에 border_red.xml입니다 : 당신이에 맞게 너무 많이했다 View
에 마진을 제공하고 있기 때문에
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
<stroke android:color="#FF0000" android:width="5dp" />
</shape>
작동하지 않았습니다. match_parent는 제가 생각한 높이 값입니다. –
좋아요, 제 대답을 편집했습니다. 시도하십시오 이제 작동 할 것입니다. – Manishika
이제 작동했습니다. 감사. –