I have 2 views that takes the whole screen and I want to display both views at the same time. My layout looks like this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:orientation="vertical">   <WebView     android:id="@+id/webview"     android:layout_width="fill_parent"     android:layout_height="fill_parent"   />   <org.example.myCustomView     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent"   /> </LinearLayout> 

Note that myCustomView uses onDraw ( this method last statement is invalidate()) to draw custom graphics. The problem I am getting that it only display myCustome view and webView is hidden. I tried to change the background color of mycustomView to transparent but this makes no difference.I would also the abilty to make mycustomeView as overlay on webView or vice versa.


answer one:

Use a RelativeLayout for starters.

You could use the ViewGroup.addView(View child, int index, ViewGroup.LayoutParams params) or a variant along with ViewGroup.removeView(View view) or ViewGroup.removeViewAt(int index).

This would obviously require you to inflate the views manually using LayoutInflater but you could keep a global reference to each after inflating and just flip between the two.


answer two:

I'm not sure if you can do this when they are in the same xml file, but I know that if you move:
<org.example.myCustomView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>

to another xml file, and create another activity. set the content view to the xml file that contains the org.example.myCustomView and call that activity. in the manifest, when you add that activity, add a theme statement as so:

android:theme="@android:style/Theme.Dialog"

the full statement should look like this:

<activity android:name=".name_of_activity"
android:label="TextToBeOnTop"
android:theme="@android:style/Theme.Dialog">
</activity>

the result will look like this (only it will be with your components instead):






更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android添加工程时出现This template dep
  2. Android SQLite 数据库 增删改查操作
  3. ionic3编译到Android 相关配置
  4. Android(安卓)TextView中显示图片
  5. android监听视频播放结束
  6. Android ApiDemos示例解析(9):App->Activi
  7. Android(安卓)完全隐藏状态栏方法
  8. Android Studio 3.0找不到Android Device
  9. android Shader类简介_渲染图像示例
  10. 不错的干货