Tag: android layout

以编程方式将TableRow添加到TableLayout不起作用

我试图通过编程方式在这里添加表格行 /* Find Tablelayout defined in main.xml */ TableLayout tl = (TableLayout) findViewById(R.id.SaleOrderLines); /* Create a new row to be added. */ TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); /* Create a Button to be the row-content. */ Button b = new Button(this); b.setText("Dynamic Button"); b.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); /* Add Button to row. */ […]

通知栏自定义视图中的animation

据我所知,我们可以使用通知pipe理器+远程视图在Android中创build通知。 我正在创build一个下载MP3文件的通知。 我想在它旁边有一个animation。 到目前为止,我从论坛上了解到,这是不可能的。 然而,我看到一个android应用程序的video,下载并显示animation旁边下载它。 链接: http : //www.youtube.com/watch?v= yNcs-sS2nFU& feature=related 有人能告诉我实现它的最好方法吗?

RelativeLayout正在全屏显示wrap_content

为什么FOOBARZ在底部没有layout_height="fill_parent"时候一直放在底部?换句话说,所有的元素都是wrap_content的高度? <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/feed_u" android:layout_width="50dip" android:layout_height="50dip" android:layout_marginLeft="5dip" android:scaleType="centerCrop" android:drawableTop="@android:drawable/presence_online" android:text="U" /> <RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/feed_u"> <ImageView android:id="@+id/feed_h" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/btn_minus" /> <ImageView android:id="@+id/feed_ha" android:layout_toLeftOf="@id/feed_h" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:drawable/btn_plus" /> <TextView android:id="@+id/feed_t" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Title"> </TextView> <TextView android:id="@+id/feed_a" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Band" android:layout_below="@id/feed_t"> </TextView> <TextView android:id="@+id/feed_s" android:layout_below="@id/feed_a" android:text="S" […]

CollapsingToolbarLayout副标题

我可以通过setTitle方法设置CollapsingToolbarLayout的标题吗? 还有一种方法来设置字幕?

如何设置android布局来支持所有的屏幕尺寸?

我正在开发Android版本2.2的程序。 我已经阅读了许多关于支持多种屏幕尺寸的文档,但仍然感到困惑。 我devise了一个布局文件,支持大屏幕和普通屏幕,当我用小屏幕尝试时,它不调整布局以适合屏幕。 我也在清单中使用了这个代码。 <supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="true" /> 小屏幕的图像在这里。 如何设置兼容小屏幕的屏幕? 我发现通过使用文件夹“布局小”的地方,但如果我使用这个项目的大小越来越大,我不想这样,所以任何人都可以build议我这样做的最好方法吗?

Android的LinearLayout与颜色资源:我做错了什么?

我遵循这个教程来为特定的Android视图创build一个颜色状态列表。 我只是希望它点击时突出显示,所以用户知道为什么屏幕刚刚改变。 当视图呈现时,我得到以下错误: org.xmlpull.v1.XmlPullParserException:二进制XML文件行#3:标签需要“drawable”属性或子标签定义drawable 我的颜色XML(在res / color / viewcolor.xml中): <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:color="#ff33ffff"/> <!– pressed –> <item android:color="#ff000000"/> <!– default –> </selector> 我的布局XML(在res / layout / myview.xml中): <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/myview" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="top" android:background="@color/viewcolor"> <!–crap in the layout–> </LinearLayout> 我错过了什么?

如何在Android中检测左侧或右侧的滑动?

我在android中有一个edittext视图。 在这个我想要检测一个左右滑动。 我可以用下面的代码把它放在空白处。 但是,当我在edittext上滑动时,这不起作用。 我该怎么做? 请让我知道如果我做错了什么。 谢谢。 使用的代码 switch (touchevent.getAction()) { case MotionEvent.ACTION_DOWN: { oldTouchValue = touchevent.getX(); break; } case MotionEvent.ACTION_UP: { float currentX = touchevent.getX(); if (oldTouchValue < currentX) { // swiped left } if (oldTouchValue > currentX ) { swiped right } break; } }

如何添加(垂直)分隔线到水平LinearLayout?

我正在尝试添加一个水平线性布局的分频器,但我无处可去。 分频器只是不显示。 我是Android的新手。 这是我的布局XML: <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" tools:context=".MainActivity" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/llTopBar" android:orientation="horizontal" android:divider="#00ff00" android:dividerPadding="22dip" android:showDividers="middle" > <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="asdf" /> <Button android:layout_width="wrap_content" android:layout_height="match_parent" android:text="asdf" /> </LinearLayout> </RelativeLayout>

在Android中dynamic添加表格行

我想创build一个布局,我需要dynamic添加表格行。 下面是表格布局xml <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/displayLinear" android:background="@color/background_df" android:orientation="vertical" > <TableRow android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/display_row" android:layout_marginTop="280dip" > </TableLayout> 行正被dynamic添加的活动文件是 public void init(){ menuDB = new MenuDBAdapter(this); ll = (TableLayout) findViewById(R.id.displayLinear); TableRow row=(TableRow)findViewById(R.id.display_row); for (int i = 0; i <2; i++) { checkBox = new CheckBox(this); tv = new TextView(this); addBtn = new ImageButton(this); addBtn.setImageResource(R.drawable.add); minusBtn = […]

devise一个Android平板电脑的应用程序

假设我想要构build2套不同的平板电脑版式。 一个600dp(7“平板1024×600)和一个720dp(10”平板1280×720或1280×800) 我明白,与Android 3.2,你现在可以指定平板布局。 我明白,但如何在Google Play上指定这是一款平板电脑应用。 有这个android:requireSmallestWidthDp指定所需的最小最小宽度。 很好,但在指南后面你可以阅读 警告:Android系统不关注这个属性,所以它不会影响你的应用程序在运行时的行为。 而是用于为您的应用在Google Play等服务上启用过滤function。 但是,Google Play目前不支持用于过滤的属性(在Android 3.2上),所以如果您的应用程序不支持小屏幕 , 则应继续使用其他大小属性。 所以它没有被系统使用,也没有被Google Play使用…所以基本上没用,对吧? 如果您的应用程序不支持小屏幕,您应该继续使用其他大小的属性。 好。 还有什么其他尺寸属性 支持屏幕之一? Xlarge:屏幕至less960dp x 720dp大:屏幕至less640dp x 480dp 1024×600的7英寸平板电脑是一个“大”的屏幕,所以我基本上必须为640×480分辨率devise一个布局,因为如果我希望我的应用程序可用于2种不同尺寸的平板电脑,我必须启用大尺寸和大尺寸屏幕。 所以我想我可以build立2套不同的布局 res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wide and bigger) res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wide and bigger) 完全忽略为较小的屏幕指定布局,但应用程序会在较小的屏幕上崩溃。 这是一种防止应用程序运行的方式,确实不够高雅。 有没有办法让应用程序仅适用于Google Play上600dp或更大的屏幕? 我很困惑。 我想制作一款仅支持平板电脑的应用程序,因为640×480手机无法在Google-Play上下载。 我想我错过了一些非常明显的东西。