Android tabwidget图标对齐文本

Android tabwidget图标对齐文本,android,android-layout,android-tablelayout,android-tabs,Android,Android Layout,Android Tablelayout,Android Tabs,您好,我已经有一个在android中使用tab widget的选项卡布局代码,每个选项卡都有自己的活动,但我得到了以下信息: 如何在红色的文本圈中向下移动 这是我的密码: 主要活动: package com.example.androidtablayout; import android.app.TabActivity; import android.content.Intent; import android.os.Bundle; import android.widget.TabHost;

您好,我已经有一个在android中使用tab widget的选项卡布局代码,每个选项卡都有自己的活动,但我得到了以下信息:

如何在红色的文本圈中向下移动

这是我的密码:

主要活动:

package com.example.androidtablayout;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class AndroidTabLayoutActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = getTabHost();

        // Tab for Photos
        TabSpec photospec = tabHost.newTabSpec("En Vivo");
        photospec.setIndicator("En Vivo", getResources().getDrawable(R.drawable.icon_songs_tab));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);

        // Tab for Songs
        TabSpec songspec = tabHost.newTabSpec("Twitter");
        // setting Title and Icon for the Tab
        songspec.setIndicator("Twitter", getResources().getDrawable(R.drawable.icon_photos_tab));
        Intent songsIntent = new Intent(this, SongsActivity.class);
        songspec.setContent(songsIntent);

        // Tab for Videos
        TabSpec videospec = tabHost.newTabSpec("Contactenos");
        videospec.setIndicator("Contactenos", getResources().getDrawable(R.drawable.icon_videos_tab));
        Intent videosIntent = new Intent(this, VideosActivity.class);
        videospec.setContent(videosIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab
        tabHost.addTab(songspec); // Adding songs tab
        tabHost.addTab(videospec); // Adding videos tab
    }
}
<?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">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>
main.xml:

package com.example.androidtablayout;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class AndroidTabLayoutActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost tabHost = getTabHost();

        // Tab for Photos
        TabSpec photospec = tabHost.newTabSpec("En Vivo");
        photospec.setIndicator("En Vivo", getResources().getDrawable(R.drawable.icon_songs_tab));
        Intent photosIntent = new Intent(this, PhotosActivity.class);
        photospec.setContent(photosIntent);

        // Tab for Songs
        TabSpec songspec = tabHost.newTabSpec("Twitter");
        // setting Title and Icon for the Tab
        songspec.setIndicator("Twitter", getResources().getDrawable(R.drawable.icon_photos_tab));
        Intent songsIntent = new Intent(this, SongsActivity.class);
        songspec.setContent(songsIntent);

        // Tab for Videos
        TabSpec videospec = tabHost.newTabSpec("Contactenos");
        videospec.setIndicator("Contactenos", getResources().getDrawable(R.drawable.icon_videos_tab));
        Intent videosIntent = new Intent(this, VideosActivity.class);
        videospec.setContent(videosIntent);

        // Adding all TabSpec to TabHost
        tabHost.addTab(photospec); // Adding photos tab
        tabHost.addTab(songspec); // Adding songs tab
        tabHost.addTab(videospec); // Adding videos tab
    }
}
<?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">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>


非常感谢。

我这样做是为了使图像和文本在选项卡上对齐:

for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) 
            {
                TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
                tv.setTextColor(Color.WHITE);
                tv.setPadding(0, 0, 0, 5);
                tv.setShadowLayer(2, 2, 2, Color.BLACK);
            } 

意思是你想要下标签或文本?我不知道你的要求是什么???向下移动文本,以便清楚地显示图标和文本,但我不知道如何尽可能地向下移动文本?添加一些空间,而不是移动文本本身只是整个选项卡,但现在文本正在减少,我如何为我的所有选项卡设置更高的高度?谢谢你,我也有解决办法,很好,为什么会这样?我试过很多教程,至少对我来说都有相同的问题