当前位置: 编程技术>移动开发
本页文章导读:
▪TableLayout惯用细节 TableLayout常用细节
列号为1的列收缩android:shrinkColumns="1"列号为2的列扩展android:stretchColumns="2"表明列号android:layout_column="1"合并列android:layout_span="2"示例:
<TableLayout
android:layout_width="wrap_conte.........
▪ 应用FrameLayout实现遮罩层 使用FrameLayout实现遮罩层
利用FrameLayout的特性,可以实现一个简单的遮罩层.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layo.........
▪ LayoutInflater中施用的注意点以及PopupWindow的使用 LayoutInflater中使用的注意点以及PopupWindow的使用
LayoutInflater:
mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null);
--->其中resLayoutId为布局文体的id,注意必须是layout级别的 :.........
[1]TableLayout惯用细节
来源: 互联网 发布时间: 2014-02-18
TableLayout常用细节
列号为1的列收缩
列号为2的列扩展
表明列号
合并列
示例:
没找到合并行的方法,继续学习...
列号为1的列收缩
android:shrinkColumns="1"
列号为2的列扩展
android:stretchColumns="2"
表明列号
android:layout_column="1"
合并列
android:layout_span="2"
示例:
<TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="1" > <TableRow> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="username" /> <EditText android:layout_column="1" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </TableRow> <TableRow> <Button android:layout_span="2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" android:layout_gravity="center" /> </TableRow> </TableLayout>
没找到合并行的方法,继续学习...
[2] 应用FrameLayout实现遮罩层
来源: 互联网 发布时间: 2014-02-18
使用FrameLayout实现遮罩层
利用FrameLayout的特性,可以实现一个简单的遮罩层.
这只是一个假象。
这只是一个假象。
确实是可以点击 楼主能说一下为什么么?比较好奇 还有这个有什么用处么?
给framelayout处理下就可以实现 禁止点击了
利用FrameLayout的特性,可以实现一个简单的遮罩层.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="show"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Mask"
/>
</LinearLayout>
</FrameLayout>
package com.ql.app;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
public class App extends Activity {
private boolean isMask = true;
private FrameLayout layout = null;
private Button btn = null;
private TextView textView = null;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
initViews();
}
private void initViews() {
layout = (FrameLayout) findViewById(R.id.layout);
btn = (Button) findViewById(R.id.btn);
btn.setOnClickListener(new MaskListener());
}
// 按钮监听,显示/隐藏遮罩
private class MaskListener implements OnClickListener {
public void onClick(View v) {
if (isMask) {
if(textView==null){
textView = new TextView(App.this);
textView.setTextColor(Color.BLUE);
textView.setTextSize(20);
textView.setText("I am a mask.");
textView.setGravity(Gravity.CENTER);
textView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT));
textView.setBackgroundColor(Color.parseColor("#33FFFFFF"));
}
btn.setText("show");
isMask = false;
layout.addView(textView);
} else {
btn.setText("hide");
isMask = true;
layout.removeView(textView);
}
}
}
}
1 楼
somefuture
2011-09-29
你的hide和show的顺序好像反了。我想问的是,既然mask显示出来了,为什么按钮还可以按呢?不是让textView给盖住了吗?
2 楼
gundumw100
2011-09-29
somefuture 写道
你的hide和show的顺序好像反了。我想问的是,既然mask显示出来了,为什么按钮还可以按呢?不是让textView给盖住了吗?
这只是一个假象。
3 楼
GaoMatrix
2011-10-07
gundumw100 写道
somefuture 写道
你的hide和show的顺序好像反了。我想问的是,既然mask显示出来了,为什么按钮还可以按呢?不是让textView给盖住了吗?
这只是一个假象。
确实是可以点击 楼主能说一下为什么么?比较好奇 还有这个有什么用处么?
4 楼
phymal
2011-11-03
LZ这个根本不是遮罩。因为下面那一层还是能操作。
5 楼
hanjiangit
2012-02-29
遮住也能操作文本框 这是为什么啊
6 楼
wxw404
2012-03-12
vistorLayout.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});给framelayout处理下就可以实现 禁止点击了
[3] LayoutInflater中施用的注意点以及PopupWindow的使用
来源: 互联网 发布时间: 2014-02-18
LayoutInflater中使用的注意点以及PopupWindow的使用
LayoutInflater:
mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null);
--->其中resLayoutId为布局文体的id,注意必须是layout级别的 : R.layout.名称
PopupWindow的使用:
PopupWindow是阻塞对话框,只有在外部线程 或者 PopupWindow本身做退出操作才行。PopupWindow完全依赖Layout做外观,在常见的开发中,PopupWindow应该会与AlertDialog常混用。
public class MenuActivity extends Activity {
private static final String TAG = "MenuActivity";
MenuPopupWindow menu1;
View lt;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lt = findViewById(R.id.ll_root);
menu1 = new MenuPopupWindow(this, R.layout.menu);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1,100,1,"menu");
Log.e(TAG, "======onCreateOptionsMenu=======");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Log.e(TAG, "======onMenuOpened=======");
/*if(menu1!= null){
if(menu1.isShowing()){
menu1.dismiss();
}else{*/
//menu1.showAtLocation(lt, Gravity.BOTTOM, 0, 0);
// }
//}
return super.onMenuOpened(featureId, menu);
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
Log.e(TAG, "======onPrepareOptionsMenu=======");
menu1.showAtLocation(lt, Gravity.BOTTOM, 0, 0);
return false;//super.onPrepareOptionsMenu(menu);
}
class MenuPopupWindow extends PopupWindow{
LinearLayout mLayout;
public MenuPopupWindow(Context context, int resLayoutId) {
super(context);
mLayout = (LinearLayout)LayoutInflater.from(context).inflate(resLayoutId, null);
this.setContentView(mLayout);
this.setWidth(LayoutParams.FILL_PARENT);
this.setHeight(LayoutParams.WRAP_CONTENT);
this.setFocusable(true);
/// 设置 popupWindow 的背景为透明色
}
}
注意这里在,onPrepareOptionsMenu这个方法中return的值是false,执行menu的顺序是:
onPrepareOptionsMenu-----true---->onMenuOpened----true---->drawmenu
最新技术文章: