我有一个relativeLayout如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:id="@+id/parent" >
<ListView
android:layout_width="360dp"
android:layout_height="600dp"
android:id="@+id/list"
android:inputType="text"
android:maxLines="1"
android:layout_margin="50dp"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
在java代码中,我想在listview的左侧添加一个视图,但它没有用:
m_relativeLayout = (RelativeLayout)findViewById(R.id.parent);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.LEFT_OF, m_listView.getId());
Button button2 = new Button(this);
button2.setText("I am button 2");
m_relativeLayout.addView(button2, layoutParams);
Run Code Online (Sandbox Code Playgroud)
只有当我将listview设置为alignParentRight时,它才会起作用.这是一个机器人的bug还是我错过了什么?
我总是尝试addView(View child, int index, LayoutParams params),但它可能只适用于线性布局.那么有一个正常的解决方案来完成RelativeLayout.LEFT_OF工作吗?
编辑
我曾尝试RelativeLayout.BELOW和RelativeLayout.RIGHT_OF,他们的工作完美,所以这意味着我没有足够的地方,以获得该按钮?我试图给予更多空间,但它仍然不起作用.
我使用东芝AT100(1280*800)和风景,所以空间足够.测试below和和.right一样left.我想如果我把一个控制器A放在relativelayout中,那么我在控制器A的左边添加控件B和decalare,结果应该是控件B将控件A推到右边,对吗?
我知道listview可以像这样在XML中设置滚动条拇指Android:scrollbarThumbVertical等.
但是我在java代码中创建了一个listview实例,我可能需要设置不同的scrollbar thumb.有没有一种方法可以通过编程方式设置滚动条拇指?
我有一个方法setData(ArrayList<super> list),所以任何想要设置数据的人都可以拥有自己的实体,只需要从超类扩展.但是当他们调用时,他们setData如何将ArrayList转换为ArrayList?
现在我使用setData(new ArrayList(list)),但这不是一个好的解决方案.
任何人都可以告诉我如何转换或其他解决方案可以避免这个问题.非常感激!
我在一个活动中显示一个编辑对话框,当软键盘显示时,活动的窗口将调整为太小,看起来很糟糕. I don't want the window of the activity be resized and layout. I just want the keyboard can cover on the activity window and the dialog move to the top so that soft keyboard have room to show.
我试图在清单中使用android:windowSoftInputMode ="xxxxx",但是没有一种模式适合我的情况.我也发现了类似的问题,但它并没有解决我的问题.
编辑:我已经尝试过setImeOptions,getWindown().setFlags但它仍然没有奏效,任何建议将非常感激.
EDIT2:我在3.0中尝试过,使用android:windowSoftInputMode ="adjustNothing",它工作得很好,但我怎么能在2.3上实现呢?
将我的SDK升级到Android L后,我在使用ant构建android项目时遇到了问题.
错误输出:
/Users/dreamtale/develop/android-sdk-macosx/tools/ant/build.xml:828: taskdef class proguard.ant.ProGuardTask cannot be found
using the classloader AntClassLoader[]
有人面临同样的问题吗?