Я переключаю действия на вкладках и успешно в этом. Но в одном из моих занятий я делаю следующее:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
main.xml имеет следующее:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#BDBDBD">
</LinearLayout>
Я хочу изменить фон только этого макета и хочу, чтобы вкладки были такими, какие они есть. Но с текущим значением android:layout_height="fill_parent"
в main.xml мой фон перезаписывает вкладки, что означает, что я не могу видеть вкладки. и если я сделаю android:layout_height="wrap_content"
, я не увижу каких-либо изменений, а вкладки все еще их.
Пожалуйста, помогите.
Вот некоторая информация ..
screen2.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout android:id="@+id/LinearLayout02"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView android:text="AcctId"
android:id="@+id/TextView01"
android:layout_width="50px"
android:layout_height="wrap_content"></TextView>
<EditText
android:id="@+id/acctid"
android:layout_width="200px"
android:layout_height="wrap_content"></EditText>
</LinearLayout>
<LinearLayout android:id="@+id/LinearLayout03"
android:layout_width="fill_parent"
android:gravity="center"
android:layout_height="wrap_content">
<TextView android:text="Zip"
android:id="@+id/TextView02"
android:layout_width="50px"
android:layout_height="wrap_content">
</TextView>
<EditText
android:id="@+id/stid"
android:layout_width="200px"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<Button android:text="Login"
android:layout_width="80px"
android:layout_height="wrap_content"
android:layout_gravity="center">
</Button>
<ImageView
android:layout_width="200px"
android:layout_height="200px"
android:src="@drawable/icon"
android:layout_gravity="center">
</ImageView>
</LinearLayout>
</ScrollView>
screen1.xml
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#c6c3c6"
android:layout_gravity="bottom"
android:paddingTop="1dip"
android:paddingLeft="1dip"
android:paddingRight="1dip">
<TabWidget
android:layout_gravity="bottom"
android:id="@android:id/tabs"
android:layout_height="wrap_content"
android:layout_width="fill_parent"/>
</FrameLayout>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</TabHost>
MainActivity.java
public class onstarAndroidMain extends TabActivity {
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.screen1);
addTabs();
}
private void addTabs(){
Resources resources = getResources();
TabHost tabs = (TabHost) findViewById(android.R.id.tabhost);
tabs.setup();
//tabspec defines the attributes of the tab
TabSpec tab;
tab = tabs.newTabSpec("Screen1");
tab.setContent(new Intent(this, Screen1.class));
tab.setIndicator("Screen1");
tabs.addTab(tab);
tabs.getTabWidget().getChildAt(0).getLayoutParams().height = 30;
tab = tabs.newTabSpec("Screen2");
tab.setContent(new Intent(this, Screen2.class));
tab.setIndicator("Screen2");
tabs.addTab(tab);
tabs.getTabWidget().getChildAt(1).getLayoutParams().height = 30;
tab = tabs.newTabSpec("Screen3");
tab.setContent(new Intent(this, Screen3.class));
tab.setIndicator("Screen3");
tabs.addTab(tab);
tabs.getTabWidget().getChildAt(2).getLayoutParams().height = 30;
//sets the current tab
tabs.setCurrentTab(0);
//add the tabhost to the main content view
}
}
Screen2.java
public class OnstarScreen2 extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.screen2);
}
Теперь, когда я нажимаю на вкладку screen2 и пытаюсь получить screen2.xml, мои вкладки располагаются ниже макета screen2. Я не знаю что делать. По сути, я хочу добиться того, чтобы вкладка всегда была внизу, независимо от того, какой вид отображается над ними. они не должны перекрываться чем-либо еще.
screen2.xml имеет вид прокрутки и, кроме того, у меня есть linearlayout с формой входа в систему ... но эта форма при вызове просто появляется над вкладками ... пожалуйста, помогите