我尝试在其他视图下进行查看,我的问题是它似乎不起作用。他们在我的代码中查看的视图不在下方。firstText
并没有在我输入的secondText
ID 下进行。感谢您的帮助:)
public void setHelper() {
linear1 = (LinearLayout) findViewById(R.id.checkHelp1);
linear2 = (LinearLayout) findViewById(R.id.layout2);
firstText = (TextView) findViewById(R.id.textView4);
secondText = (TextView) findViewById(R.id.timer);
linear1.setVisibility(View.GONE);
linear2.setVisibility(View.GONE);
RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp2.addRule(RelativeLayout.BELOW, R.id.checkNeedHelp);
firstText.setLayoutParams(lp2);
lp2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
lp2.addRule(RelativeLayout.BELOW, R.id.addNewExercise);
lp2.setMargins(0, 25, 0, 0);
secondText.setLayoutParams(lp2);
}
XML 代码
<?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"
android:background="@drawable/background"
android:orientation="vertical" >
<EditText
android:id="@+id/editRoutine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/routines"
android:ems="10"
android:hint="add new routine"
android:textColorHint="@color/black" >
</EditText>
<TextView
android:id="@+id/timer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/layout2"
android:text="Routine exercsies" />
<Spinner
android:id="@+id/routineExercises"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/timer"
android:layout_toLeftOf="@+id/deleteExerciseFromRoutine" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/routineExercises"
android:text="Choose exercise to add to selected routine" />
<Spinner
android:id="@+id/exerciseForRoutine"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView2"
android:layout_toLeftOf="@+id/addExercisesToRoutine" />
<ImageButton
android:id="@+id/addExercisesToRoutine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/exerciseForRoutine"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_input_add" />
<ImageButton
android:id="@+id/addNewRoutine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/routines"
android:src="@android:drawable/ic_input_add" />
<ImageButton
android:id="@+id/deleteExerciseFromRoutine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_alignParentRight="true"
android:src="@drawable/close" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/deleteExerciseFromRoutine"
android:layout_alignParentRight="true" />
<ImageButton
android:id="@+id/removeRoutine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/routines"
android:layout_toRightOf="@+id/routineExercises"
android:src="@drawable/close" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Edit Routines"
android:textSize="30sp" />
<LinearLayout
android:id="@+id/checkHelp1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/checkNeedHelp"
android:background="@color/gray"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Manage routines"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add new routines or delete one from the list" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editRoutine"
android:layout_marginTop="25sp"
android:background="@color/gray"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Routine exercies"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add exercies to selected routine or delete one" />
</LinearLayout>
<LinearLayout
android:id="@+id/swipeLayOut2"
android:layout_width="110sp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="@color/Black"
android:orientation="vertical"
android:visibility="gone" >
<Button
android:id="@+id/goHomePage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="home page"
android:textSize="15sp" />
<Button
android:id="@+id/goCalendar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Calendar"
android:textSize="15sp" />
<Button
android:id="@+id/goLive"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="live workout"
android:textSize="15sp" />
<Button
android:id="@+id/goToday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Today log"
android:textSize="15sp" />
<Button
android:id="@+id/goProgram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Program plan"
android:textSize="15sp" />
<Button
android:id="@+id/goPersonal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pesonal detials"
android:textSize="15sp" />
<Button
android:id="@+id/goWorkout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Set workout"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/checkHelp1"
android:text="Routines" />
<Spinner
android:id="@+id/routines"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView4"
android:layout_toLeftOf="@+id/removeRoutine" />
<CheckBox
android:id="@+id/checkNeedHelp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="25sp"
android:text="Need help?"
android:textSize="13sp" />
<com.example.workoutlog.VerticalTextView
android:id="@+id/swipeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/swipeLayOut2"
android:background="@color/red"
android:text="swipe right"
android:textSize="18sp" />
</RelativeLayout>