Tag: android layout

出现软键盘时如何调整布局

我想调整/重新调整软键盘的布局,如下图所示: 之前和之后: 在SO中find了一些资源: 如何在显示软键盘时保持所有字段和文本可见 出现的时候,android软键盘会破坏布局 软键盘开启时调整布局 但是问题和答案是相当含糊的,下面是我想要的更清晰的问题。 要求: 它应该在任何屏幕尺寸的手机上工作。 注意到“FACEBOOK”和“注册Facebook”的保证金/填充空间在之前和之后都发生了变化。 不涉及滚动视图。

ListView Items Android之间的间距

我试图在listView上使用marginBottom来在listView Item之间留出空间,但是仍然把这些项目连接在一起。 这甚至有可能吗? 如果是的话,有没有一个具体的方法来做到这一点? 我的代码如下 <LinearLayout android:id="@+id/alarm_occurences" android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" android:background="#EEEEFF" xmlns:android="http://schemas.android.com/apk/res/android"> <ListView android:id="@+id/occurences" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </LinearLayout> 我的自定义列表项目: <com.android.alarm.listItems.AlarmListItem xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/alarm_item_background" android:layout_marginBottom="10dp" > <CheckedTextView android:id="@android:id/text1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_vertical" android:checkMark="?android:attr/listChoiceIndicatorMultiple" android:textSize="20sp" android:textStyle="bold" android:typeface="serif" android:padding="10dp" /> </com.android.alarm.listItems.AlarmListItem> 在这种情况下,我怎样才能在列表项之间进行间隔?

Android XML布局参数不能按预期的方式运行

我有3个问题: imageView(白色瓷砖)比gridView中的其他瓷砖显得大得多(这很奇怪,因为它只设置为5dp x 5dp) 在我的editText上设置android:layout_alignParentRight =“true”,textView和imageView似乎不会将图像移动到右侧 android:layout_below =“@ id / sqwhite”似乎不把我的editText放在我的textView下 (基本上来说:我需要在右下angular正确设置这些尺寸,但是我所用的参数都没有任何影响。) 有任何想法吗? <?xml version="1.0" encoding="utf-8"?> <com.example.project.DragLayer xmlns:android="http://schemas.android.com/apk/res/android" xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher" android:id="@+id/drag_layer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color/black" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="1.0" > <GridView android:id="@+id/image_grid_view" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="0.8" android:background="@color/grid_background" android:gravity="center" android:horizontalSpacing="2dip" android:numColumns="@integer/num_columns" android:stretchMode="columnWidth" android:verticalSpacing="2dip" /> <RelativeLayout android:id="@+id/bottom_part" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_weight="0.2" android:background="@android:color/black" […]

InflateException:二进制XML文件行#1:由于OutOfMemoryError引起的类错误

这是我的代码: input.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" android:background="@drawable/background_main" > <ImageView android:id="@+id/logo_image" android:background="@drawable/background_green" android:src="@drawable/titleimage" android:layout_width="match_parent" android:layout_height="50dp" /> <ScrollView android:id="@+id/scroller" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/logo_image" android:layout_marginTop="10dp" > <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:stretchColumns="*" > <TableRow android:id="@+id/device_type_row" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingTop="5dp" android:paddingBottom="5dp" android:layout_marginRight="5dp" > <RadioButton android:id="@+id/device_type_radio" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/device_type" /> <RadioGroup android:id="@+id/device_type_radio_selection" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <RadioButton android:id="@+id/radioIos" android:layout_width="wrap_content" android:layout_height = […]

如何在小部件右侧没有向下三angular形的情况下创buildandroid微调器

我有一个屏幕,用户有很多项目input,所以屏幕空间是非常宝贵的。 我希望屏幕上的小部件的外观(在用户按下之前)与微控制器右侧的EditText或Spinner小部件的左侧部分(没有正常的向下三angular形)类似。 然后当用户按下小部件时,他/她将得到正常的微调器select对话框。 有一些微调样式属性,我可以改变来完成这个? 我一直无法看到这样的代码。 谢谢

将触摸事件传递给父视图

我有一个自定义ViewSwitcher ,我实现了触摸事件,所以我可以使用触摸屏滚动屏幕。 我的布局层次结构如下所示: <ViewSwitcher> <LinearLayout> <ListView /> </LinearLayout> <LinearLayout> <ListView /> </LinearLayout> </ViewSwitcher> 现在,问题是触摸事件正在被ListViews消耗,我无法切换视图。 当我没有ListViews时它工作正常。 我需要能够滚动浏览和滚动ListView 。 我如何解决这个问题? 编辑 :我也需要ListView项目可点击。 提前致谢!

如何在android中使网格视图水平滚动

我已经写了GridView的代码,我可以显示图像和文字,但我想显示在单个可滚动的行像脉冲新闻应用程序中的所有图像。 我已经在xml中为gridview实现了horizo​​ntalscroll-view,但是根本不起作用。 我正在使用pageviwer的标签,我正在使用片段。 这是我的xml代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <HorizontalScrollView android:id="@+id/horizontalScrollView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:fillViewport="true" android:scrollbars="horizontal" > <GridView android:layout_width="500dp" android:layout_height="400dp" android:id="@+id/gridview" android:columnWidth="300dp" android:numColumns="3" android:horizontalSpacing="10dp" android:scrollbars="horizontal"> </GridView> </HorizontalScrollView> </RelativeLayout> 这是我的图像adpator代码 public class ImageAdapter extends BaseAdapter { private Context context; private final String[] mobileValues; private TextView t; public ImageAdapter(Context context, String[] mobileValues) { this.context = context; this.mobileValues = […]

Appcompatv7 – v21导航抽屉不显示汉堡包图标

我正在实施与最新的appcompat支持库棒棒糖风格的抽屉,但问题是汉堡包图标从不显示。 只显示返回图标。 这是我的活动代码 import android.os.Bundle; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.widget.Toolbar; import android.view.View; public class Home extends ActionBarActivity { private DrawerLayout mDrawerLayout; private ActionBarDrawerToggle mDrawerToggle; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); initViews(); } private void initViews(){ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); toolbar.setTitleTextColor(getResources().getColor(android.R.color.white)); setSupportActionBar(toolbar); mDrawerToggle = new ActionBarDrawerToggle(this, […]

EditText maxLines不工作 – 用户仍然可以input比设置更多的行

<EditText android:id="@+id/editText2" android:layout_height="wrap_content" android:layout_width="fill_parent" android:maxLines="5" android:lines="5"> </EditText> 用户可以input5行以上,按enter / next row键。 如何使用EditText将用户input限制为固定数量的行?

在Android中使用负边距是不好的做法吗?

负保证金演示: 场景 通过为其中一个设置负边距来重叠视图,以便它侵入另一个视图的边界框。 思考 它似乎以你期望的方式工作,如果他们应该重叠的布局。 但我不想在不知不觉中做一件更大的事情。 仿真器,物理设备,你命名它,当你使用负边界一切似乎工作正常,一个视图侵入另一个视图的边界框,并根据它如何在布局中声明它将在另一个视图之上或之下。 我也知道,因为API 21我们可以设置translationZ和elevation属性,使视图出现在其他视图的上方或下方,但我的关注基本上来自这样一个事实,即在 layout_margin属性的文档中清楚地指定了margin值应该是积极的 ,让我引用: 摘抄: 在该视图的左侧,顶部,右侧和底部指定额外的空间。 这个空间在这个视图的范围之外。 保证金值应该是正值 。 必须是一个维度值,这是一个浮点数字,附加一个单位如“14.5sp”。 可用的单位是:px(像素),dp(密度独立像素),sp(基于首选字体大小的缩放像素),单位为英寸,毫米(毫米)… 自从问起这个问题以来,我一直没有任何负利润的问题,尽量避免使用它们,但是没有遇到任何问题,所以即使文件说明,我也不是担心它。