如何防止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) 我如何实现以下布局,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
实现这一目标的想法.有人知道更好的方法吗?
谢谢
我有一个由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?