如何通过搜索栏移动来更改背景图像?

时间:2015-03-28 06:13:18

标签: java android xml

在我的应用程序中,我想显示当我的活动搜索栏发生变化时,从白天到夜晚的背景变化。 我做了一个显示搜索栏的新活动,显示时间。当“时间”在A.M.时,背景应显示为天,否则应显示夜晚。

1 个答案:

答案 0 :(得分:0)

这是我到目前为止所做的事情

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#ff00ff">

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:background="#ffffff" >

        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="52dp"
            android:inputType="text"
            android:hint="@string/network_name"
            android:layout_centerHorizontal="true"
            android:textSize="@dimen/txt_15sp" />

        <SeekBar
            android:id="@+id/seek1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:progress="0"
            android:max="100"
            android:layout_marginTop="48dp"
            android:layout_below="@+id/editText1"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Size of Network"
            android:id="@+id/textView1"
            android:textSize="@dimen/txt_15sp"
            android:layout_below="@+id/seek1"
            android:layout_centerHorizontal="true" />

        <SeekBar
            android:id="@+id/seek2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:progress="0"
            android:max="100"
            android:layout_marginTop="38dp"
            android:layout_below="@+id/textView1"
            android:layout_centerHorizontal="true" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Duration of Network"
            android:id="@+id/textView2"
            android:textSize="@dimen/txt_15sp"
            android:layout_below="@+id/seek2"
            android:layout_centerHorizontal="true" />

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Next"
            android:id="@+id/button"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="42dp"
            android:layout_centerHorizontal="true" />



    </RelativeLayout>
</LinearLayout>
相关问题