我想在Web视图的中心设置此进度条:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity = "center_vertical|center_horizontal">
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</WebView>
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) 当我layout_marginLeft在代码中使用或设置左边距时,它可以用作layout_marginRight.此行为被视为当我放置View用layout_marginLeft在FrameLayout或在Android API <11的布局的根.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:background="#77cc99"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:background="#eebbaa">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MyActivity"
/>
</FrameLayout>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud) 这有点难以描述,但我会尽我所能:
我正在开发一个使用自定义相机活动的Android应用程序.在此相机活动中,我使用以编程方式创建表面视图并将其设置为在xml布局文件中定义的framelayout(覆盖全屏).
我现在的问题是,如何在框架布局中添加其他元素?只能以编程方式?我问,因为到目前为止,我只能以编程方式添加其他元素.我在xml布局中添加的元素没有出现在屏幕上.它们可能只是我添加到框架布局的表面视图的后面吗?如果是这样,是否可以将它们带到前线?
感谢你们!
这是我现在的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/tablet_locations_fragment_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/tablet_locations_fragment_locations_fragment_list_container"
android:layout_width="match_parent"
android:layout_height="90dp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我认为很明显,我希望底部框架布局为90dp高和高,以占据剩余的空间,但目前,上部框架布局占据了所有的屏幕高度.我怎样才能解决这个问题?我试图将layout_height ="wrap_content"用于上部框架布局,但它没有改变任何东西.
我正在使用以下命令在frameLayout上绘制边框:
frameLayout.setForeground(getResources().getDrawable(R.drawable.blue_border));
Run Code Online (Sandbox Code Playgroud)
现在我想删除这个前景drawable ..我怎么能这样做?
我正在尝试添加自定义边框framelayout.将framelayout被用作用于该片段的容器.因此,我想显示带边框的片段.边框应该在framelayout外部,不应占用framelayout内部的空间.它应该根据屏幕尺寸的变化进行调整.

我现在能想到的是某种自定义ViewGroup,为边框添加ImageView.使用图像处理来获取imageview的内部区域,并在该区域中扩展帧布局.
我正在寻找一些简单的方法.
我在 xml 中有一个 frameLayout:
<FrameLayout
android:layout_width="150px"
android:layout_height="200px"
android:id="@+id/preview">
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
此预览用于显示相机视图:
mPreview = new CameraSurfacePreview(MainActivity.this, cameraObj,...);
preview.addView(mPreview2);
....
Run Code Online (Sandbox Code Playgroud)
它成功地从前置摄像头显示人脸。我有面部矩形 x 和 y 坐标。如何在frameLayout上显示人脸边界框?
谢谢你。
我有以下Android XML布局文件:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/AutoComplete_marginSides"
android:layout_marginRight="@dimen/AutoComplete_marginSides"
android:layout_marginTop="@dimen/AutoComplete_marginTopBottom"
android:layout_marginBottom="@dimen/AutoComplete_marginTopBottom"
android:layout_marginLeft="@dimen/AutoComplete_marginSides"
android:layout_marginStart="@dimen/AutoComplete_marginSides"
android:id="@+id/autoCompleteLayout" >
<MyPackage.maps.DelayAutoCompleteTextView
android:id="@+id/geoAutoComplete"
android:layout_margin="@dimen/AutoCompleteTextView_layoutMargin"
android:layout_width="match_parent"
android:layout_height="@dimen/AutoCompleteTextView_height"
android:layout_gravity="center"
android:gravity="start|center_vertical"
android:inputType="textCapSentences"
android:background="@color/white"
android:paddingLeft="@dimen/AutoCompleteTextView_padding"
android:paddingRight="@dimen/AutoCompleteTextView_padding"
android:dropDownWidth="fill_parent"
android:textSize="@dimen/AutoCompleteTextView_fontSize"
android:hint="@string/search_map"
android:elevation="2dp"
android:singleLine="true"
android:maxLength="30"/>
<ImageView
android:id="@+id/geoAutoCompleteClear"
android:layout_gravity="center_vertical|end"
android:contentDescription="@string/search_map_clear"
android:layout_marginEnd="@dimen/AutoCompleteTextView_clearIconMargins"
android:layout_marginRight="@dimen/AutoCompleteTextView_clearIconMargins"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_clear"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
该FrameLayout布局内的RelativeLayout(我没有表现出高于)。这FrameLayout只是文本视图,末尾带有叉号以删除文本。
问题是,当我添加android:elevation到TextView该ImageView云背后的TextView,尽管它不应该,因为我定义后TextView本身。据我所知,子序列决定了如何显示组件。但是,当我elevation从中删除时TextView,ImageView显示正确。
我在这里想念什么吗?这是什么原因呢?
添加此行时,应用程序崩溃
`requestWindowFeature(Window.FEATURE_NO_TITLE);
可能解决方案很简单,但我真的不知道该修复它的人.
Java代码:
public class GLSurfaceCameraSurfaceDemo2Activity extends Activity {
/** Called when the activity is first created. */
GLSurfaceView glSurfaceView;
FrameLayout fl01;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
requestWindowFeature(Window.FEATURE_NO_TITLE);
}
Run Code Online (Sandbox Code Playgroud)
}
XML文件:
<FrameLayout
android:id="@+id/fl01"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Run Code Online (Sandbox Code Playgroud) 我有以下布局(这里提供了更简单的设计):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main">
<FrameLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hey, badge!"
android:layout_margin="10dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AAAAA"
android:layout_margin="10dp"
android:textSize="12sp"
android:background="#ff00ff"
android:padding="10dp"
android:layout_gravity="top|end"
/>
</FrameLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我希望将TextView设置为文本"AAAA"以充当Button的徽章,即将其放置在其右上角的按钮上,但事实并非如此.
相反,当我在带有Lollipop的HTC One M7或带有Lollipop的Genymotion Nexus 6上尝试此代码时,屏幕看起来像这样:
当我使用KitKat在Genymotion Nexus 5上尝试相同的代码时,一切看起来都符合预期,即第一个视图(按钮)显示在徽章(textview)下面
有没有人知道这里有什么问题?
谢谢,Deveti