在滚动活动上设置图像背景

时间:2016-07-07 16:05:06

标签: android scroll background

我想更改标准生成的ScrollingActivity(到图像)的背景。
更改content_scrolling.xml的背景会影响我可以放置项目的区域仅

我错过了一个简单的方法吗? (我很惊讶我无法找到答案,所以我们走了)

the blue background should be replaced by an image

3 个答案:

答案 0 :(得分:5)

更改android.support.design.widget.CollapsingToolbarLayout的背景属性

<android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed"
        android:background="@drawable/backgraound">

或更改android.support.design.widget.AppBarLayout

的背景属性
<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/app_bar_height"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme.AppBarOverlay"
    android:background="@drawable/backgraound">

答案 1 :(得分:0)

最后编辑

为什么不创建一个正常的活动(public void setTextSize(float size) { if (mTextPaint.getTextSize() != size) { mTextPaint.setTextSize(size); setLineSpecs(); } layoutText(mHeight); } )及其背景,然后在其中LinearLayout

ScrollView

编辑:

也许您可以查看这个lgvalle/Material-Animations库。

答案 2 :(得分:0)

我认为您正在寻找的是“FrameLayout”。它的工作方式类似于堆栈或图层布局。每个新生儿都可以放在前一个孩子的前面。

一个例子:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/your_image" />

    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#99acd347"
        android:gravity="center"
        android:text="Android" />
</FrameLayout>

在这里,你将在TextView后面有一个ImageView。

相关问题