草庐IT

bundle-layout

全部标签

android - 何时将 subview 从 XML 添加到 Layout/ViewGroup

我的问题是:我想知道xLayout(或一般的ViewGroup)何时从XML添加subview?我所说的“何时”是指在代码的哪个点,在UI工具包的“遍历”的哪个“channel”中?我应该覆盖xLayout或ViewGroup的哪个方法?我做了功课:我看过"WritingCustomViewsForAndroid"在上次GoogleI/O中提出(由AdamPowell和RomainGuy),我已经阅读了AdamPowell对此Google+post的评论. 最佳答案 LookingfortheexactpointinAndroid'

android - 什么是android :layout_gravity ="clip_vertical" exactly

android:layout_gravity="clip_vertical|horizo​​ntal"属性执行SDK文档中提到的以下操作:Additionaloptionthatcanbesettohavethetopand/orbottomedgesofthechildclippedtoitscontainer'sbounds.Theclipwillbebasedontheverticalgravity:atopgravitywillclipthebottomedge,abottomgravitywillclipthetopedge,andneitherwillclipbothedg

android - 我如何找出 android.R.layout xml 文件的样子/获取源代码?

我正在尝试使用LayoutInfator来创建View。我正在考虑的选项之一是使用默认的android.R.layout文件。但是我发现很难找到这些文件/它们的外观。如果我能在定位源方面得到一些帮助,那就太好了。我需要在这些xml文件中找到各个元素的ID。谢谢 最佳答案 它们可以在您的AndroidSDK文件夹中找到:/platforms/android-x/data/res/layout 关于android-我如何找出android.R.layoutxml文件的样子/获取源代码?,我们

android - 我想在 Bundle 中打包一个枚举值并作为枚举获取

我有这样的枚举enumStatus{READY,DISCONNECTED,RECEIVING,...more}我想通过Bundle将此枚举的值发送到另一个线程。另一个线程想从Bundle中提取枚举值,如何聪明地做到这一点?BundlecreateBundle(Statusstatus);和StatusgetStatus(Bundleb);谢谢, 最佳答案 由于Enum是可序列化的,我们可以使用以下方法将枚举打包到bundle中:publicstaticStringMY_ENUM="MY_ENUM";myBundle.putSeria

android - 如何在android中设置Layout的最大高度?

我必须像这样实现布局;如果其中的内容较少,则布局应将内容包裹起来。如果内容超出某个大小,例如300dp,则应将其设置为最大高度(300dp)并且能够滚动。如果没有任何解决方法,是否有任何属性可以这样做? 最佳答案 您可以找到设备的显示尺寸。根据显示尺寸你可以设置layoutparams。例如,如果显示尺寸小于300dp,您可以将height设置为wrapcontent。如果大于300dp表示将height设置为300dp。示例代码如下:WindowManagerwm=(WindowManager)ctx.getSystemServi

android:layout_alignParentBottom 在没有显式布局高度的情况下被忽略作为 ListView 中的一行

当我使用RelativeLayout时,将fill_parent或wrap_content作为高度,并指定一个元素:android:layout_alignParentBottom="true"它被忽略并在顶部对齐。将RelativeLayout的高度设置为一个明确的值使其工作。有什么线索吗? 最佳答案 这似乎是Android本身的一个错误,请参阅http://code.google.com/p/android/issues/detail?id=1394.我通过包装我的RelativeLayout解决了这个问题在FrameLayou

android - CoordinatorLayout layout_anchor 不起作用

我刚刚试用了带有CoordinatorLayout的新支持设计库,但我在锚定subview时遇到了问题。我的布局目前看起来像这样:当加载RecyclerView列表时,第一项与操作栏重叠。我假设app:layout_anchor没有正常工作。我已经尝试将它锚定到appbar但没有成功。有谁知道我在这里做错了什么? 最佳答案 试试这段代码。您需要在RecyclerView中使用app:layout_behavior 关于android-CoordinatorLayoutlayout_anc

android - 如何确定 intent 持有的 bundle 中 extra 的类型?

我试图通过Intent将任意数据传递给BroadcastReceiver。所以我可能会做类似下面的事情intent.putExtra("Someboolean",false);intent.putExtra("Somechar",'a');intent.putExtra("SomeString","Butdon'tknowwhatitwillbe");intent.putExtra("Somelong",15134234124125);然后将其传递给BroadcastReceiver我想用keySet()之类的东西遍历Intent.getExtras(),但我也希望能够在没有必须对.g

android - 约束布局布局崩溃 : All Children of constraint layout should have ids to use constraint set

更新到com.android.support.constraint:constraint-layout:1.1.0之后约束布局崩溃说:Allchildrenofconstraintlayoutshouldhaveidstouseconstraintset我已经为所有View设置了id,即使它崩溃了。java.lang.RuntimeException:AllchildrenofConstraintLayoutmusthaveidstouseConstraintSetatandroid.support.constraint.ConstraintSet.clone(ConstraintSe

android - Android 中的 bundle 有限制吗?

我想知道androidbundle的数据大小是否有上限。我尝试按大小>80k的包发布数据,并抛出android致命异常。数据是可序列化的。 最佳答案 这取决于bundle的用途。bundle本身仅受内存量的限制。bundle的两个主要用途是使用Intent在组件之间传递信息和保存Activity的状态。1。Intent/Binder当用于在Android组件之间传递信息时,bundle被序列化为一个Binder事务。进程中所有Binder事务的总大小为1MB。如果超过此限制,您将收到此fatalerror“!!!FAILEDBIND