小编Wel*_*sen的帖子

applicationId显示占位符,表示多个构建版本无法正常工作

我正在修改当前的android项目,因此它可以安装在同一设备上,用于多种口味和构建配置.

的build.gradle:

{
    // ...
    defaultConfig {
        applicationId "com.myapp"
        manifestPlaceholders = [
            manifestApplicationId: "${applicationId}",
            onesignal_app_id: "xxxx",
            onesignal_google_project_number: "xxxx"
        ]
    // ...
    }

    productFlavors {
        production {
            applicationId "com.myapp"
            // ...
        }

        dev {
            applicationId "com.myapp.dev"
            // ...
        }

        // ...
    }

    buildTypes {
        release {
            // ...
        }

        debug {
            applicationIdSuffix ".debug"
            // ...
        }
    }

    // ...
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml:

<manifest ... >
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <permission
    android:name="${applicationId}.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />      
    <!-- ... -->

    <receiver
        android:name="com.onesignal.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action …
Run Code Online (Sandbox Code Playgroud)

android buildconfig gradle android-manifest manifest-merging

7
推荐指数
1
解决办法
6810
查看次数

无论屏幕大小和方向如何,如何使Android布局成比例

这是我在此的头一篇博文.我刚刚学习了Android编程并遇到了这个问题.我搜索了一下,发现了一些解决方案,但我无法使我的代码工作.所以我想知道我的代码或实现的哪一部分是错误的.

所以,问题是我想制作一个在不同屏幕尺寸和方向上保持相同比例的布局.这是我的代码:

activity_main.xml中

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:baselineAligned="false"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="150dp" >
        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:gravity="left"
            android:id="@+id/textView1"/>
        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:gravity="right"
            android:id="@+id/textView2"/>
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:id="@+id/textView3"/>
    </LinearLayout>

    <LinearLayout
        android:layout_weight="1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:gravity="left"
            android:id="@+id/textView4"/>

        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:id="@+id/textView5"/>

        <TextView
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:gravity="right"
            android:id="@+id/textView6"/>
    </LinearLayout>

    <SeekBar
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/seekBar"
        android:max="255"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我目前无法发布截图,因为它说"发布图片需要至少10个声望."

因此,我希望将屏幕垂直划分为3个部分,并将顶部水平分割为2,将底部水平分为3,并保持其比例,无论屏幕尺寸,分辨率和方向如何.

唯一没有用的部分是顶部块,在我设置它的代码上,android:layout_height="150dp"因为如果我设置它们,布局会以某种方式被破坏android:layout_height="fill_parent".但是,如果我改变方向,这不会使布局成比例.任何帮助将不胜感激.

谢谢.

android orientation android-layout screen-size

6
推荐指数
2
解决办法
4126
查看次数