自定义控件getChildCount()得到总是1

qq_27490689 qq_27490689 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
以下是自定义组合控件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" >
</ImageView>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:alpha="0.5"
android:background="@android:color/background_dark"
android:ellipsize="marquee"
android:gravity="center"
android:focusable="true"
android:lines="1"
android:marqueeRepeatLimit="marquee_forever"
android:paddingBottom="30px"
android:scrollHorizontally="false"
android:text="云端美食"
android:textSize="40px"
android:textStyle="bold" >

</TextView>

</RelativeLayout>
在实现类中:
public class ImageTextView extends RelativeLayout
{

public ImageTextView(Context context, AttributeSet attrs)
{
super(context, attrs);
// TODO Auto-generated constructor stub
LayoutInflater flater = LayoutInflater.from(context);
flater.inflate(R.layout.custom_imagetext, this);
int count=getChildCount();
}
}
int count=getChildCount()为什么得到的总是1,而我的控件中有两个元素。请高人指点。
...全文
评论 6
收藏 已收藏
分享
返回顶部
qq_27490689
Android 80,490 成员 91,375 内容