Tag: android layout

Android在视图之间绘制一条水平线

我有我的布局如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Twitter Feeds" android:textStyle="bold" /> <ListView android:id="@+id/list" android:layout_width="350dp" android:layout_height="50dp" /> <TextView android:id="@+id/textView1" style="@style/behindMenuItemLabel1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:text="FaceBook Feeds" /> <ListView android:id="@+id/list1" android:layout_width="350dp" android:layout_height="50dp" /> </LinearLayout> 我的要求是在TextView和ListView之间绘制一条水平线 谁能帮忙?

为什么0dp被认为是性能提升?

填补了这个问题的答案 ,结合了言论和解决scheme。 题 我周围search,但没有发现任何真正解释为什么Android Lint以及一些Eclipse提示build议用0dpreplace一些layout_height和layout_width值。 例如,我有一个build议改变的ListView 之前 <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"> </ListView> 后 <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> 同样,它build议对ListView项目进行更改。 这些在变化之前和之后都是一样的,但我有兴趣了解为什么这些是性能提升者。 任何人都有解释为什么? 如果有帮助,这里是与ListView总体布局。 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:id="@+id/logo_splash" android:layout_width="match_parent" android:layout_height="wrap_content"> </ImageView> <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@color/background" android:layout_below="@id/logo_splash"> <ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1"> </ListView> <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/no_upcoming" /> </LinearLayout> </RelativeLayout> 回答 我在这里给出了一个答案,因为它实际上是下面的答案和参考链接的组合。 […]

我怎样才能检测到我的应用程序Androidselect哪个布局?

假设我在不同的资源文件夹中有三种不同布局的活动。 例如: layout-land/my_act.xml layout-xlarge/my_act.xml layout-xlarge-land/my_act.xml 在不同的设备和不同的位置,其中一个是由Androidselect的。 我怎样才能找出哪一个是编程select? Android是否有任何将这些布局返回给程序的API? 编辑 : Graham Borland的解决scheme在我提到的一些情况下有问题。

Android图像缩放animation相对于中心点

我有一个ImageView,我做了一个简单的缩放animation。 非常标准的代码。 我的scale_up.xml: <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromXScale="1" android:fromYScale="1" android:toXScale="1.2" android:toYScale="1.2" android:duration="175"/> </set> 我的animation代码: Animation a = AnimationUtils.loadAnimation(this, R.anim.scale_up); ((ImageView) findViewById(R.id.circle_image)).startAnimation(a); 问题: 当图像缩放时,不会从中心缩放,而是从左上angular缩放。 换句话说,图像的缩放比例与中心不一样,但左上angular相同。 这是一个链接,解释我的意思。 第一个图像是animation的缩放比例,第二个图像是我想如何缩放的。 它应该保持中心点一样。 我已经尝试在图像上设置重力,在容器上左右alignment,总是缩放相同。 我使用RelativeLayout作为主屏幕,ImageView被放置在另一个RelativeLayout中,但是我尝试了其他布局,没有改变。

添加的EditText不是TextInputEditText。 请切换到使用该类

我在TextInputLayout使用EditText ,但是在将支持库升级到23.2.0之后,我在logcat中得到了这个警告,常规EditText和TextInputEditText什么区别? 我似乎无法find任何文件。

在API 17之前从RelativeLayout中移除规则

在API 17之前,如何从布局中删除规则? 我有一个RelativeLayout与一些孩子。 RelativeLayout是我的活动的主要布局。 以编程方式添加规则后使用 RelativeLayout.LayoutParams layout = (LayoutParams) theChild.getLayoutParams(); layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); 我需要稍后以编程方式删除规则。 我会如何做这个假设比17更早的API?

引起:java.lang.UnsupportedOperationException:无法转换为维:type = 0x1

在Android中我有仿真器和一些移动设备,但不是在平板电脑中的错误 : 我不明白有什么错误? 我search了很多教程,但找不到任何解决scheme。 请帮我解决这个问题。 注意:在这个应用程序中,我使用了ActionbarSherlock和主题,可能是因为那个库或其他问题? 我的错误日志是: 09-11 17:52:57.342: E/AndroidRuntime(9935): FATAL EXCEPTION: main 09-11 17:52:57.342: E/AndroidRuntime(9935): android.view.InflateException: Binary XML file line #2: Error inflating class <unknown> 09-11 17:52:57.342: E/AndroidRuntime(9935): at android.view.LayoutInflater.createView(LayoutInflater.java:613) 09-11 17:52:57.342: E/AndroidRuntime(9935): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 09-11 17:52:57.342: E/AndroidRuntime(9935): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 09-11 17:52:57.342: E/AndroidRuntime(9935): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 09-11 17:52:57.342: E/AndroidRuntime(9935): at android.view.LayoutInflater.inflate(LayoutInflater.java:466) 09-11 17:52:57.342: E/AndroidRuntime(9935): at […]

Android:如何让视图增长以填充可用空间?

这似乎很简单,但我不知道如何去做。 我有一个EditText和两个ImageButtons的水平布局。 我想ImageButtons是一个固定的大小,EditText占据布局中的剩余空间。 这怎么能做到呢? <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content"> </EditText> <ImageButton android:src="@drawable/img1" android:layout_width="50dip" android:layout_height="50dip"> </ImageButton> <ImageButton android:src="@drawable/img2" android:layout_width="50dip" android:layout_height="50dip"> </ImageButton> </LinearLayout>

如何在Android布局的视图中心?

我想把一个布局放在屏幕的中心。

格式语句在一个string资源文件中

我有像这样在通常的strings.xml资源文件中定义的string: <string name="hello_world"> HELLO</string> 是否可以定义如下所示的格式string result_str = String.format("Amount: %.2f for %d days ", var1, var2); 在strings.xml资源文件中? 我试图逃脱特殊字符,但它不工作。