【发布时间】:2013-12-05 08:15:10
【问题描述】:
您好,我正在开发一款安卓视频应用。我的框架布局上有按钮。我需要大一点的按钮。但是当我在屏幕上看到预览时,它们正在缩小。 Video.xml 如下所示
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<FrameLayout
android:id="@+id/videoview"
android:layout_width="720px"
android:layout_height="480px" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/mybutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:src="@drawable/record_video" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RadioButton
android:id="@+id/flashoff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="OFF"
android:textSize="8dp" />
<RadioButton
android:id="@+id/flashtorch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Torch"
android:textSize="8dp" />
</RadioGroup>
</LinearLayout>
</LinearLayout>
oncreate 如下
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.videocapture);
DisplayMetrics metrics = this.getResources().getDisplayMetrics();
vwidth = metrics.widthPixels;
vheight = metrics.heightPixels;
Log.e("vwidth"," "+vwidth);
Log.e("vheight"," "+vheight);
//Get Camera for preview
myCamera = getCameraInstance();
if(myCamera == null)
{
Toast.makeText(VideoCapture.this,"Fail to get Camera",Toast.LENGTH_LONG).show();
}
myCameraSurfaceView = new MyCameraSurfaceView(this, myCamera);
final FrameLayout myCameraPreview = (FrameLayout)findViewById(R.id.videoview);
myCameraPreview.addView(myCameraSurfaceView);
myCameraPreview.post(new Runnable()
{
@Override
public void run()
{
int width = vwidth;
int height = vheight;
LayoutParams lp = myCameraPreview.getLayoutParams();
lp.height = height;
lp.width = width - 80;
myCameraPreview.setLayoutParams(lp);
}
});
recVideo = (ImageView)findViewById(R.id.mybutton);
recVideo.setOnClickListener(myButtonOnClickListener);
flashOff = (RadioButton)findViewById(R.id.flashoff);
flashTorch = (RadioButton)findViewById(R.id.flashtorch);
}
我该如何解决这个问题。请帮忙。谢谢
【问题讨论】:
-
FrameLayout在你的情况下似乎没有孩子。 -
需要修正 FrameLayout 的高度和宽度吗?
-
您的应用仅支持横向模式吗?你为什么使用 720 像素和 480 像素?
-
android-er.blogspot.in/2011/10/… 我参考了上面的链接,是的,我正在横向模式下尝试
标签: android xml android-framelayout