小编gde*_*nte的帖子

ImageButton具有不同的状态图像大小

如何防止ImageButton固定尺寸?选择器中使用的drawable具有不同的大小,我希望ImageButton自己调整大小以匹配图像大小.

我试过adjustViewBounds没有成功.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="8dp" >

    <ImageButton
        android:id="@+id/picture_imagebutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:src="@drawable/tab_background_selector" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

android imagebutton android-layout

9
推荐指数
1
解决办法
2285
查看次数

Android - 具有右对齐视图的Ellipsize

我如何实现以下布局,TextView是一个TextView带有ellipsize的结尾,而View wrap_content正好位于TextView的右边?

以下是布局应如何表现的三个示例,具有不同的TextView宽度:

|[TextView] [View]              |

|[TextView TextView] [View]     |

|[TextView TextView T...] [View]|
Run Code Online (Sandbox Code Playgroud)

[编辑]

以下TableLayout给出了正确的行为:

<TableLayout
    android:id="@+id/upper_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/alert_button"
    android:shrinkColumns="0"
    android:stretchColumns="2" >

    <TableRow>

        <TextView
            android:id="@+id/name_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:ellipsize="end"
            android:includeFontPadding="false"
            android:lines="1"
            android:paddingTop="2dp"
            android:scrollHorizontally="true" />

        <TextView
            android:id="@+id/unread_count_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:gravity="center"
            android:includeFontPadding="false"
            android:paddingBottom="0dp"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:paddingTop="2dp" />
    </TableRow>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

TableLayout使用3列,最后被破解:该strechColumns特性使得它采取一切可用的空间,所以第二个TextView总是立刻到第一个的右边.TextView由于shrinkColumns属性,第一个正确的椭圆化.

但是,我不喜欢使用a TableLayout实现这一目标的想法.有人知道更好的方法吗?

谢谢

layout android alignment

6
推荐指数
1
解决办法
1271
查看次数

AAR不包括模块的资源

我有一个由2个模块组成的Android库:

Project Root
+-- moduleA
|   +-- src
|   \-- build.gradle
|
+-- moduleB
|   +-- src
|   \-- build.gradle
|
+-- build.gradle
+-- settings.gradle
Run Code Online (Sandbox Code Playgroud)

settings.gradle

include ':moduleB', 'moduleA'
Run Code Online (Sandbox Code Playgroud)

moduleA /的build.gradle

apply plugin: 'com.android.library'
...
dependencies {
    compile project(':moduleB')
}
Run Code Online (Sandbox Code Playgroud)

moduleB /的build.gradle

apply plugin: 'com.android.library'
...
Run Code Online (Sandbox Code Playgroud)

当我尝试使用gradle生成的AAR时,不包括moduleB的资源.我试图将两个AAR推送到maven本地,但结果相同.

如果我将moduleA的类型更改为application而不是library,则生成的APK包含正确的资源.

我应该怎么做才能获得包含两个模块资源的AAR?

java resources android gradle aar

6
推荐指数
1
解决办法
442
查看次数