基本上,我有两个 XML 文件
- 周.xml
- weekone.xml
week.xml 的代码
<?xml version="1.0" encoding="UTF-8"?>
<!--
Begin Relative Layout
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true"
android:background="@drawable/appbackground">
<TextView
android:id="@+id/about_title"
android:layout_width="fill_parent"
android:layout_height="49dp"
android:background="#00141c"
android:fontFamily="Hobo Std"
android:gravity="center"
android:text="@string/start"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#FFFFFF"
android:textSize="25sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/backarrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:src="@drawable/arrow"/>
<ImageView
android:id="@+id/week4"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="24dp"
android:clickable="true"
android:paddingTop="400dp"
android:src="@drawable/weekfour" />
<ImageView
android:id="@+id/week3"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/week4"
android:clickable="true"
android:paddingTop="400dp"
android:src="@drawable/weekthree" />
<ImageView
android:id="@+id/week2"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/week3"
android:clickable="true"
android:paddingTop="400dp"
android:src="@drawable/weektwo" />
<ImageView
android:id="@+id/week1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/week2"
android:clickable="true"
android:paddingTop="400dp"
android:src="@drawable/weekone" />
<TextView
android:id="@+id/hinttext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/week1"
android:layout_below="@+id/backarrow"
android:layout_marginTop="162dp"
android:gravity="center_vertical"
android:text="Press week1 to start workout" />
<!--
End of Relative Layout
-->
</RelativeLayout>
weekone.xml 的代码
<?xml version="1.0" encoding="UTF-8"?>
<!-- Begin of Linear Layout -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="400dp"
android:orientation="vertical"
android:background="@drawable/screenbackground"
android:paddingTop="70dp" >
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<TextView
android:id="@+id/week1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/week1"
android:textColor="#FFFFFF"
android:textSize="25sp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:background="#00141c"/>
<!-- Begin Scrollable Relative Layout -->
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true">
<ImageView
android:id="@+id/treadmillimage"
android:layout_width="115dp"
android:layout_height="93dp"
android:paddingTop="10dp"
android:src="@drawable/treadmill" />
<EditText
android:id="@+id/durOnTreadmill"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:layout_marginLeft="180dp"
android:layout_centerVertical="true"/>
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<!-- End Relative Layout -->
</RelativeLayout>
<TextView
android:id="@+id/treadmilltext"
android:layout_width="91dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/treadmill"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<!-- Begin Relative Layou -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true">
<ImageView
android:id="@+id/stepperimage"
android:layout_width="115dp"
android:layout_height="93dp"
android:paddingTop="10dp"
android:src="@drawable/stepper" />
<EditText
android:id="@+id/durOnStepper"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:layout_marginLeft="180dp"
android:layout_centerVertical="true"/>
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<!-- End Relative Layout -->
</RelativeLayout>
<TextView
android:id="@+id/steppertext"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/stepper"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<!-- Begin Relative Layout -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true">
<ImageView
android:id="@+id/stationaryrowing"
android:layout_width="115dp"
android:layout_height="93dp"
android:paddingTop="10dp"
android:src="@drawable/stationaryrowing" />
<EditText
android:id="@+id/durOnStationaryRowing"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:layout_marginLeft="180dp"
android:layout_centerVertical="true"/>
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<!--
End Relative Layout
-->
</RelativeLayout>
<TextView
android:id="@+id/stationaryrowingtext"
android:layout_width="108dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/stationaryrowing"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<!-- Begin Relative Layout -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true">
<ImageView
android:id="@+id/exercisebikeimage"
android:layout_width="115dp"
android:layout_height="93dp"
android:paddingTop="10dp"
android:src="@drawable/ellipticaltrainer"/>
<EditText
android:id="@+id/durOnexcerisebike"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:layout_marginLeft="180dp"
android:layout_centerVertical="true"/>
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<!-- End Relative Layout -->
</RelativeLayout>
<TextView
android:id="@+id/excerisebiketext"
android:layout_width="91dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/exercisebike"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<!-- Begin Relative Layout -->
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="true">
<ImageView
android:id="@+id/ellipticaltrainerimage"
android:layout_width="115dp"
android:layout_height="93dp"
android:paddingTop="10dp"
android:src="@drawable/ellipticaltrainer"/>
<EditText
android:id="@+id/durOnellipticaltrainer"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:layout_marginLeft="180dp"
android:layout_centerVertical="true"/>
<!-- Line seperator -->
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:id="@+id/separator"
android:visibility="visible"
android:background="#00141c"/>
<!-- End Relative Layout -->
</RelativeLayout>
<TextView
android:id="@+id/ellipticaltrainertext"
android:layout_width="91dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:text="@string/ellipticaltrainer"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</ScrollView>
<!--
End Linear Layout
-->
</LinearLayout>
所以,我想要实现的是,当我按下可点击的 ImageView 第 1 周时,它会隐藏 Textview“hintText”并在同一活动上执行 weekone.xml。我已经查看了 FrameLayout,因为它用于将布局放在彼此之上,并且我希望看到两种布局,因此不适合我的需求。ViewFlipper 用于在按下空白区域时更改布局,但我希望在按下按钮“第 1 周”时更改布局
请帮忙,我从 2 天以来一直在尝试解决这个问题,但没有高兴:(。谢谢 :)