找了很久,终于找到了。
<?xml version="1.0" encoding="UTF-8" ?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:okCancelBar="http://schemas.android.com/apk/res/com.example.android.merge">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="center"
android:src="@drawable/golden_gate"
/>
<com.example.android.merge.OkCancelBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:paddingTop="8dip"
android:gravity="center_horizontal"
android:background="#AA000000"
okCancelBar:okLabel="Save"
okCancelBar:cancelLabel="Don't save"
/>
</merge>
com.example.android.merge.OkCancelBar是一个自定义的GROUP
public class OkCancelBar extends LinearLayout{
public OkCancelBar(Context context,AttributeSet attrs){
super(context, attrs);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER);
setWeightSum(1.0f);
LayoutInflater.from(context).inflate(R.layout.okcancelbar,this,true);
TypedArray array= context.obtainStyledAttributes(attrs, R.styleable.OkCancelBar,0,0);
String text= array.getString(R.styleable.OkCancelBar_okLabel);
if(text==null) text="Ok";
((Button) findViewById(R.id.okcancelbar_ok)).setText(text);
text= array.getString(R.styleable.OkCancelBar_cancelLabel);
if(text==null) text="Cancel";
((Button) findViewById(R.id.okcancelbar_cancel)).setText(text);
array.recycle();
}
}
LayoutInflater.from(context).inflate(R.layout.okcancelbar,this,true);
直接从XML中得到一个VIEW加入到当前GROUP中
okcancelbar.xml:
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<include layout="@layout/okcancelbar_button" android:id="@+id/okcancelbar_ok"/>
<include layout="@layout/okcancelbar_button" android:id="@+id/okcancelbar_cancel"/>
</merge>
分享到:
相关推荐
Android——给控件添加动画 为一个Layout里面的控件,或者右是一个ViewGroup里面的控件设置动画。
代码为博客实例代码:http://blog.csdn.net/lmj623565791/article/details/38352503 有问题请博客留言
ViewGroup存在的目的就是为了对其子View进行管理,为其子View...因此,自定义ViewGroup通常需要重写onMeasure()方法来对子View进行测量,重写onLayout()方法来确定子View的位置,重写onTouchEvent()方法增加响应事件。
android中继承ViewGroup用法 android中继承ViewGroup用法 android中继承ViewGroup用法
使用ViewGroup的导航页面实例.欢迎大家下载学习
android自定义viewGroup仿Scrollview详解
这是android viewgroup view 源码,有一些注释,此源码仅供学习使用。
这是一个Gradle工程,Gradle的版本是2.10,项目的Compile sdk Version是 23 , Build Tools Version 为23.0.2. 2.如果没有用android studio的同学,可以先安装apk看效果,apk地址为MeizuDemo\app\build\outputs\...
通过前一篇博客View的事件分发机制,从dispatchTouchEvent说起(一)的介绍相信大家对 Android View 事件的分发机制有了很深的理解。我们知道 Android 中 View 是存在于 Activity。 今天我们继续学习 Activity 到 ...
原文地址http://blog.csdn.net/android_cmos/article/details/52356229
该资源包含了一个利用自定义的viewgroup实现的slidingmenu,简单易懂。
android自定义viewgroup实现等分格子布局
代码为博客实例代码:http://blog.csdn.net/lmj623565791/article/details/38339817, 有问题请博客留言
一个类似思维导图软件的ViewGroup
Android自定义ViewGroup 滑动
ViewGroup存在的目的就是为了对其子View进行管理,为其子View...因此,自定义ViewGroup通常需要重写onMeasure()方法来对子View进行测量,重写onLayout()方法来确定子View的位置,重写onTouchEvent()方法增加响应事件。
Android 自定义ViewGroup实现整个Item布局竖直跑马灯效果,详细看我的博客讲解
主要介绍了Android自定义ViewGroup(侧滑菜单)详解及简单实例的相关资料,需要的朋友可以参考下
本文实例讲述了Android继承ViewGroup实现Scroll滑动效果的方法。分享给大家供大家参考,具体如下: extends ViewGroup需要重写onMeasure和onLayout方法 onMeasure方法是去测量ViewGroup需要的大小以及包含的子View...
Android 标签,可以自动换行的ViewGroup