Tag: android layout

LinearLayout不在ScrollView内部扩展

我有一个在android:layout_height="fill_parent"的ScrollView里面有一个LinearLayout ,但是它不会展开到ScrollView的全部高度。 我的布局看起来像这样: level layout layout_width layout_height 1 LinearLayout fill_parent fill_parent 2 LinearLayout fill_parent wrap_content 3 (some irrelevant stuff) 2 ScrollView fill_parent fill_parent <– this expands full height 3 LinearLayout fill_parent fill_parent <– this does not (has orientation=vertical) (following stuff probably are irrelevant, but just to be sure:) 4 TextView fill_parent fill_parent 4 LinearLayout fill_parent […]

您需要使用Theme.AppCompat主题(或后代)与此活动

Android Studio 0.4.5 用于创build自定义对话框的Android文档: http : //developer.android.com/guide/topics/ui/dialogs.html 如果您想要自定义对话框,则可以将对话框显示为对话框,而不是使用对话框API。 只需创build一个活动并将其主题设置为<activity> manifest元素中的Theme.Holo.Dialog: <activity android:theme="@android:style/Theme.Holo.Dialog" > 但是,当我尝试这个我得到以下exception: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity 我支持以下内容,我不能使用超过10分钟的东西: minSdkVersion 10 targetSdkVersion 19 在我的风格,我有以下几点: <!– Base application theme. –> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 在我的清单中,我有这样的活动: <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:theme="@android:style/Theme.Holo.Light.Dialog" android:name="com.ssd.register.Dialog_update" android:label="@string/title_activity_dialog_update" > </activity> 像这样创build对话框是我正在跳跃的事情,因为我已经完成了布局。 […]

Android布局文件中的“工具:上下文”是什么?

从ADT的新版本开始,我已经注意到布​​局XML文件中的这个新属性,例如: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" /> 什么是“工具:上下文”用于? 它甚至如何知道写在那里的活动的确切path? 它是否在清单中查看应用程序的包? 它仅限于扩展上下文的类还是仅限于活动? 它可用于ListView项目等?

在Android 4.0+上移除操作栏左侧图标的填充

我想在标准的Android 4.0+操作栏左边的图标周围删除填充。 我正在设置图标: getActionBar().setIcon(getResources().getDrawable(R.drawable.ic_action_myapp)); 我希望图标垂直填充空间,触摸顶部和底部,类似于soundcloud应用程序所做的:

Android – 多行的线性布局

我需要一个多行布局,这将performance为水平线性布局,但是当没有足够的空间来放置新的小部件时,它会扩展到下一行,就像文本中的文字一样。 小部件将在运行时添加到那里,并且应该使用wrap_content 。 其实,会有button。 有没有这种行为的小部件? 或者给我一个关于如何自己写这样的布局的build议。 最后它应该是这样的:

MonoDroid:调用自定义视图的构造函数时出错 – TwoDScrollView

我正在构build一个使用定制的TwoDScrollView在这里find的Android应用程序: http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/ 这个类可以在其他几个网站上find,Stack Overflow的其他人也提出了一些问题。 我在之前使用Java / Eclipse构build的Android应用程序中使用了它,而且我取得了成功。 用我目前的应用程序,我想使用C#和MonoDroid。 我决定用C#重写整个TwoDScrollView类。 重写后,然后在一些布局XML中使用它,当我尝试运行我的代码时,出现以下exception: System.NotSupportedException已被抛出。 无法从本地句柄44f4d310激活types为MyProject.TwoDScrollView的实例。 System.Exception:没有为MyProject.TwoDScrollView ::。ctor(System.IntPtr,Android.Runtime.JniHandleOwnership)find构造函数……更多的文本后面…. 我的布局XML如下所示: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <myproject.TwoDScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> </myproject.TwoDScrollView> </RelativeLayout> 按照以下链接中关于在MonoDroid中使用布局XML中的自定义视图的说明: http ://docs.xamarin.com/android/advanced_topics/using_custom_views_in_a_layout TwoDScrollView类的构造函数如下所示: public TwoDScrollView(Context context) : base(context) { initTwoDScrollView(); } public TwoDScrollView(Context context, IAttributeSet attrs) : base(context, attrs) { initTwoDScrollView(); } public TwoDScrollView(Context context, […]

CardView layout_width =“match_parent”与父RecyclerView宽度不匹配

我有一个片段,其中包含一个带有layout_width =“match_parent”的RecyclerView: <android.support.v7.widget.RecyclerView 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:layout_gravity="center" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity$PlaceholderFragment" /> RecyclerView中的项目也是一个CardView,也是layout_width =“match_parent”: <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:id="@+id/card_view" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_margin="20dp" card_view:cardCornerRadius="4dp"> <TextView android:layout_gravity="center" android:id="@+id/info_text" android:layout_width="match_parent" android:gravity="center" android:layout_height="match_parent" android:textAppearance="?android:textAppearanceLarge"/> </android.support.v7.widget.CardView> 我膨胀的项目视图如下: public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { CardView v = (CardView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.card_listitem, null, true); ViewHolder vh = new ViewHolder(v); return […]

如何添加一个开关到android动作栏?

我想添加一个类似于jellybean原生外观的button开关。 (视图顶部的蓝色/灰色开关) 文档显示了如何在那里创build菜单或添加图标,但是并没有说明如何添加自定义元素。 例如。 一个开关。 http://developer.android.com/guide/topics/ui/actionbar.html

如何在带有圆angular的android中查看视图

我正在尝试使用圆angular边缘在Android中的视图。 我目前find的解决scheme是定义一个圆angular的形状,并将其用作该视图的背景。 这是我做的,定义一个drawable如下所示 <padding android:top="2dp" android:bottom="2dp"/> <corners android:bottomRightRadius="20dp" android:bottomLeftRadius="20dp" android:topLeftRadius="20dp" android:topRightRadius="20dp"/> 现在我用这个作为我的布局的背景如下 <LinearLayout android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:layout_marginBottom="10dp" android:clipChildren="true" android:background="@drawable/rounded_corner"> 这工作非常好,我可以看到,视图圆润的边缘。 但是我的布局在其中有很多其他的子视图说一个ImageView或一个MapView。 当我在上面的布局中放置一个ImageView时,图像的angular落不会被剪切/裁剪,而会显得满了。 我已经看到了其他的解决方法,使它像这里解释的工作。 但有没有一种方法来设置一个视图的圆angular,所有的子视图都包含在那个圆angular的主视图中? 谢谢。

我可以在运行时,编程设置“android:layout_below”吗?

是否有可能在运行时创build相对布局,以编程方式设置等效的android:layout_below ?