Android xml选项卡有问题
这是我在应用程序中的标签 我做错了什么? 我的活动\u main.xmlAndroid xml选项卡有问题,android,xml,tabs,Android,Xml,Tabs,这是我在应用程序中的标签 我做错了什么? 我的活动\u main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:srcCompat="@drawable/header_logo" />
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
我的第一个活动xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="59.908008"
mapbox:mapbox_cameraTargetLng="30.319100"
mapbox:mapbox_cameraZoom="8"/>
</FrameLayout>
第二项活动
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
app:srcCompat="@drawable/mapbox_compass_icon" />
<TextView
android:id="@+id/idtest"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Информация"></TextView>
</LinearLayout>
我需要这样的设计
我不明白问题出在哪里,我从俄语论坛的课程中创建了所有内容(我说俄语)您的xml文件已经准备好了
接下来,将此代码放入MainActivity.java文件中,以便在TabHost中添加选项卡
//Assign id to Tabhost.
TabHostWindow = (TabHost) findViewById(android.R.id.tabhost);
//Creating tab menu.
TabSpec TabMenu1 = TabHostWindow.newTabSpec("First tab");
TabSpec TabMenu2 = TabHostWindow.newTabSpec("Second Tab");
//Setting up tab 1 name.
TabMenu1.setIndicator("Tab1");
//Set tab 1 activity to tab 1 menu.
TabMenu1.setContent(new Intent(this, TabActivity_1.class));
//Setting up tab 2 name.
TabMenu2.setIndicator("Tab2");
//Set tab 3 activity to tab 1 menu.
TabMenu2.setContent(new Intent(this, TabActivity_2.class));
TabHostWindow.addTab(TabMenu1);
TabHostWindow.addTab(TabMenu2);
有关更多信息,请访问您只需添加一个单独的布局文件,其中包括选项卡和操作栏我通过styles.xml中的
false true
修复第一个屏幕,但我不知道如何设计,因为在第三个屏幕上您不了解我,我做了一个工人阶级。我需要在xml代码中通过imageview在选项卡上方创建徽标,我注册了它,但它在启动时不显示。您的问题是header_徽标不可见,然后使用android:src=“@drawable/header_logo”而不是app:srcCompat=“@drawable/header_logo”Himalay comment help me))