2

私は自分のカメラアプリを展開しています。そのために、横向きのSurfaceViewを標準で使用しています。

私がやろうとしているのは、SurfaceView を膨らませてボタンを持たせることです。しかし、ほとんどのストックカメラアプリのように、ボタンを縦向きの下部の中央に表示したい. 膨らませているボタンのレイアウトは次のとおりです。コントロールのどの組み合わせで目的の結果が得られるかわかりません。

私のレイアウト:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="right"
    >
<Button
    android:id="@+id/takepicture"  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text=" * Take Picture " 
        android:layout_alignParentRight="true" 
        android:layout_centerVertical="true" 
    android:layout_margin="10px"
    />
</LinearLayout>

ご協力いただきありがとうございます!=]

4

2 に答える 2

0

遊んでlayout_weightください。これを試して:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="right"
>
<com.YOURSurfaceView android:layout_width="fill_parent" android:background="#ff0" android:layout_weight=".2"
android:layout_height="fill_parent" >

</com.YOURSurfaceView>
<Button
android:id="@+id/takepicture"  
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:text=" * Take Picture " 
    android:layout_weight="1"
android:layout_margin="10px"
/>
</LinearLayout>
于 2012-06-04T03:34:40.630 に答える
-1

答えてくれてありがとうアレス。ここでもう少し掘り下げて、LinearLayoutを使用した解決策を見つけましたが、私が理解していることから、すべてがその場所にありますが、一般的に、RelativeLayoutの方がパフォーマンスが優れているので、少し実験してみました。 。ボタンとして画像を使用しているので、プレスなどで他のボタンを含めてアップグレードし、適切に拡大縮小することをお勧めします(これは次に行います)。しかし、必要最低限​​では、これが私のために働いていることです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:gravity="right"
    android:orientation="horizontal" >
    <RelativeLayout
        android:layout_width="40dp"
        android:layout_height="fill_parent"
        android:gravity="center_vertical" >
        <ImageButton
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/lens_2" />
    </RelativeLayout>
</RelativeLayout>

上記は私のSurfaceViewで膨らんでおり、次のように宣言しています。

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

mPreview = new CameraPreview(this);
setContentView(mPreview);

LayoutInflater controlInflater = LayoutInflater.from(getBaseContext());
View viewControl = controlInflater.inflate(R.layout.control, null);
LayoutParams layoutParamsControl 
    = new LayoutParams(LayoutParams.MATCH_PARENT, 
    LayoutParams.MATCH_PARENT);
this.addContentView(viewControl, layoutParamsControl);

}

お役に立てれば。

于 2012-06-06T23:20:06.850 に答える