【问题标题】:change android label name and gravity in androidmanifestfile在 androidmanifestfile 中更改 android 标签名称和重力
【发布时间】:2012-10-03 09:57:09
【问题描述】:

您好,我必须开发一个示例应用程序。在这里我希望选择应用程序名称为 Admin Login 并且重力为中心。在这里我必须运行该应用程序意味着应用程序名称已成功显示。但重力不适用于我。这里我想把应用名称对齐。我该怎么做。请给我解决方案。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidlogin.ws"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".AndroidLoginExampleActivity"
        android:label="Admin Login"  android:theme="@style/CustomTheme"   android:gravity="center">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
  </application>

  </manifest>

编辑:

  <style name="CustomWindowTitleBackground"> 
    <item name="android:background">#093f7c</item> 
    <item name="android:gravity">center</item>
 </style> 
 <style name="CustomTheme" parent="android:Theme"> 
    <item name="android:windowTitleSize">35dip</item>
    <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
 </style>

【问题讨论】:

  • 一个 Google 搜索给了我这个:stackoverflow.com/questions/8767655/… 似乎工作。
  • @Christiaan de Jong:这对我不起作用。所以问的问题
  • @user1676640 定义自己的风格并查看 ram kirans 评论
  • @Ramkiran 我在这里使用了以下代码: 这里背景颜色设置成功。但我的重力只剩下了。但我希望将重力设为中心。

标签: android android-manifest


【解决方案1】:

我检查了你的风格。在那里你指定

<item name="android:gravity">center</item>

CustomWindowTitleBackground。这是不可能的,因为设置重心意味着它将与其父级对齐。所以不可能将布局宽度赋予fill_parent

所以我认为你必须使用自定义 xml 文件并对齐你的标题

【讨论】:

    【解决方案2】:

    定义自定义标题样式/主题。 还可以检查 com.example.android.apis.app.CustomTitle。

    【讨论】:

      【解决方案3】:

      尝试在 AndroidLoginExampleActivity.xml 文件中设置重力

      <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
      android:id="@+id/layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"  
      android:orientation="vertical"
      android:gravity ="center" >
      

      或者如果你想在子布局中使用重力,那么在子布局中使用 layout_gravity。

      【讨论】:

        猜你喜欢
        • 2020-05-05
        • 1970-01-01
        • 2018-06-10
        • 2019-12-26
        • 2019-02-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多