我不能找到一种方法,如何使的LinearLayout不透明。它总是透明的,无论我做什么。
的布局是这样的:
<的FrameLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_height =match_parent
机器人:layout_width =match_parent>
<的LinearLayout
机器人:方向=垂直
机器人:ID =@ + ID / error_panel
机器人:layout_width =match_parent
机器人:背景=@色/ gray_background_dark
机器人:layout_height =WRAP_CONTENT>
<的TextView
机器人:ID =@ + ID / ERROR_MESSAGE
机器人:文本=@字符串/ dummy_number
机器人:重力=center_vertical |左
机器人:文字颜色=@色/红
机器人:layout_width =match_parent
机器人:layout_marginTop =5DP
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =@扪/ activity_horizontal_margin
机器人:layout_marginRight =@扪/ activity_horizontal_margin
机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>
<! - 这个滚动视图的内容看到errorPanel下 - >
<滚动型
机器人:layout_height =match_parent
机器人:layout_width =match_parent>
<! - 滚动型的内容 - >
< /滚动型>
< /的FrameLayout>
我怎么能做出的LinearLayout不透明?的可能,而不是只设置颜色,我可以尝试使用固态绘制..?
背景
我使用appcompat V7的主题<样式名称=AppTheme父=Theme.AppCompat.NoActionBar>
事情
覆盖主题的panelBackground从透明到<项目名称=机器人:panelBackground> @android:彩色/黑白LT; /项目>
设置背景背景=#FF000000
上的LinearLayout。
设置字母为的α= 1
上的LinearLayout。
设为背景绘制安卓背景=@可绘制/ background_error_panel
,其中可绘是:
<形状的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:形状=矩形>
[固体机器人:颜色=#FF181818/>
< /形状>
修改2015年3月25日
也许动画是问题..?我使用的规模anims和code:
公共无效切换(){
panel.setText(有些文字部分的文字部分的文字部分文字部分文字);
动画的slideIn = AnimationUtils.loadAnimation(MyApplication.context,R.anim.slide_in);
动画滑出= AnimationUtils.loadAnimation(MyApplication.context,R.anim.slide_out);
如果(layout.getVisibility()== View.GONE){
layout.setVisibility(View.VISIBLE);
layout.startAnimation(的slideIn);
layout.setAlpha(1);
} 其他 {
layout.startAnimation(滑出);
layout.setVisibility(View.GONE);
}
}
解决方案
这是你的滚动型是透明的。由于每文档,
子视图绘制成堆叠,顶部最近添加的孩子。
所以,你需要加载滚动型首先把它在后台运行。
I cannot find a way how to make linearLayout opaque. It's always transparent no matter what I do.
The layout looks like this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/error_panel"
android:layout_width="match_parent"
android:background="@color/gray_background_dark"
android:layout_height="wrap_content">
<TextView
android:id="@+id/error_message"
android:text="@string/dummy_number"
android:gravity="center_vertical|left"
android:textColor="@color/red"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- The content of this scroll view is seen underneath the errorPanel -->
<ScrollView
android:layout_height="match_parent"
android:layout_width="match_parent">
<!-- Content of ScrollView -->
</ScrollView>
</FrameLayout>
How can I make the LinearLayout opaque? Maybe instead of setting just color I could try to use a solid drawable..?
Background
I am using appcompat v7 theme <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
Things I tried
Override the theme's panelBackground from transparent to<item name="android:panelBackground">@android:color/black</item>
Set background as background=#FF000000
on LinearLayout.
Set alpha as alpha=1
on LinearLayout.
Set background as drawable android:background="@drawable/background_error_panel"
where the drawable is:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#FF181818"/>
</shape>
Edit 3/25/2015
Maybe the animations are the problem..? i use scale anims and in code:
public void toggle() {
panel.setText("Some text Some text Some text Some text Some text ");
Animation slideIn = AnimationUtils.loadAnimation(MyApplication.context, R.anim.slide_in);
Animation slideOut = AnimationUtils.loadAnimation(MyApplication.context, R.anim.slide_out);
if (layout.getVisibility() == View.GONE) {
layout.setVisibility(View.VISIBLE);
layout.startAnimation(slideIn);
layout.setAlpha(1);
} else {
layout.startAnimation(slideOut);
layout.setVisibility(View.GONE);
}
}
解决方案
It is your ScrollView being transparent. As per the docs,
Child views are drawn in a stack, with the most recently added child on top.
So you need to load the ScrollView first to have it in the background.
相关推荐
最新文章