Вопрос по android, xml – Android, как изменить <элемент> ширину и высоту

28

Error: User Rate Limit Exceeded<layer-list>Error: User Rate Limit Exceeded

Error: User Rate Limit Exceededandroid:layer_widthError: User Rate Limit Exceededandroid:layer_height.

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <item
        android:drawable="@drawable/picuser" 
        android:layout_width="50dp"
        android:layout_height="50dp" />

    <item
        android:drawable="@drawable/ic_launcher" 
        android:layout_width="10dp"
        android:layout_height="10dp" />
</layer-list>

Ваш Ответ

6   ответов
1

<?xml version="1.0" encoding="utf-8"?>
<!-- The android:opacity=”opaque” line is critical in preventing a flash 
of black as your theme transitions. -->
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:opacity="opaque">

    <!-- The background color, preferably the same as your normal theme -->
    <item android:drawable="@android:color/white" />

    <item
        android:height="100dp"
        android:width="100dp"
        android:gravity="center">

        <bitmap
            android:src="@drawable/ic_launcher_bc_512"/>
    </item>
</layer-list>
2

mToolbar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            ImageView imageView = (ImageView)mToolbar.findViewById(R.id.logo);
            if (mToolbar == null)
                return;
            int toolbarWidth = mToolbar.getWidth();
            int imageWidth = imageView.getWidth();
            imageView.setX((toolbarWidth - imageWidth) / 2);
        }
    });

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    style="@style/Toolbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/toolbar_height"                                                                   
    android:background="@drawable/toolbar_background"
    android:focusable="false"                                
    app:titleTextAppearance="@style/AppTheme.Toolbar.Title">

    <ImageView
        android:id="@+id/logo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/toolbar_logo" />
</android.support.v7.widget.Toolbar>
8

<item>
android:widthandroid:heightDrawableandroid:layout_widthandroid:layout_heightViewmatch_parentwrap_contentmatch_parentandroid:gravityleft|rightstart|endtop|bottom

API 23.

match_parentandroid:widthandroid:height<size><shape>

<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">

    <item>

        <shape
            android:shape="rectangle">

            <size
                android:width="152dp"
                android:height="152dp"/>

            <solid
                android:color="#00FFFFFF"/>
        </shape>
    </item>

    <item>

        <bitmap
            android:gravity="left|right|top|bottom"
            android:src="@mipmap/ic_launcher"/>
    </item>
</layer-list>

<item><shape><bitmap>android:gravityleft|top|right|bottom<bitmap><item>

EDIT:

android:windowBackground

EDIT:

API 26android:widthandroid:heightAPI 23).
API < 23API >= 23

8

<item
    android:drawable="@drawable/splash_logo"
    android:height="100dp"
    android:width="100dp"/>

NOTE:android:widthandroid:heightandroid:layout_widthandroid:layout_height

29


<item android:drawable="@drawable/circyle" />

<item
    android:drawable="@drawable/plus" 
    android:top="10dp"
    android:bottom="10dp"
    android:right="10dp"
    android:left="10dp" />

Error: User Rate Limit Exceeded
18

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/picuser"/>

    <item>

        <bitmap
            android:src="@drawable/ic_launcher"
            android:gravity="center" />
    </item>
</layer-list>

, <item>layout_width/layout_height

Error: User Rate Limit Exceeded Asaf Nevo
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы