我的注册表格LinearLayout如下所示:

当仿真器屏幕处于默认位置时,它工作正常.但是当我旋转模拟器屏幕时,它只显示适合屏幕的元素,剩下的元素就会结束.如下面的屏幕所示:

现在我想让这个布局可滚动但不能理解.任何帮助将受到高度赞赏.
我正在创建一个应用程序并在昨天发布了一个问题, 如何通过单击行中的任何位置来启动活动.有想法在下面做,但我收到此错误:
The method setOnClickListener(View.OnClickListener) in the type View is not applicable for the arguments (new OnClickListener(){})
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
LinearLayout menu_photos = (LinearLayout )findViewById(R.id.picture_part);
menu_photos.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent picture_intent = new Intent(CurrentActivity.this,PictureActivity.class);
startActivity(picture_intent );
}
});
Run Code Online (Sandbox Code Playgroud)
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_background"
android:orientation="vertical" >
<include
android:id="@id/includeTop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
layout="@layout/private_space_title" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="@id/mail_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_list_bg"
android:orientation="vertical"
android:paddingBottom="10.0dip"
android:paddingLeft="20.0dip"
android:paddingRight="20.0dip"
android:paddingTop="15.0dip" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我为整个应用设置了默认主题.它在styles.xml中定义如下:
<style name="DefaultTheme" parent="@android:style/Theme.Holo.Light">
<!-- Customization here -->
</style>
Run Code Online (Sandbox Code Playgroud)
我还定义了一个黑暗的主题:
<style name="DarkTheme" parent="@android:style/Theme.Holo">
<!-- Customization here -->
</style>
Run Code Online (Sandbox Code Playgroud)
在清单中,它被声明为轻主题作为应用程序的主题:
<application
...
android:theme="@style/DefaultTheme" >
Run Code Online (Sandbox Code Playgroud)
现在这个工作正常,但在一个活动中,我需要为单个布局设置不同的主题.像这样的东西:
+--------------------------------------------------+
| Parent Linear layout (default theme) |
| |
| +------------------------------------+ +-------+ |
| | | | | |
| | Left linear layout | | | |
| | (default theme) | | | |
| | | | | |
| | | | | |
| | | | ·<----------- Right Linear …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的层次结构:
我希望能够通过迭代添加上面的层次结构,只要有数据可以从数据库中获取(使用Parse)
我已经尝试在父LinearLayout下放置ImageView和LinearLayout但它似乎不起作用.这是我在MainActivity.Java中的代码:
LinearLayout LL_Outer = (LinearLayout) findViewById(R.id.new_linearLayoutOuter);
LL_Outer.setOrientation(LinearLayout.VERTICAL); // set orientation
LL_Outer.setBackgroundColor(color.white); // set background
// set Layout_Width and Layout_Height
LinearLayout.LayoutParams layoutForOuter = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
LL_Outer.setLayoutParams(layoutForOuter);
LinearLayout LL_Inner = (LinearLayout) findViewById(R.id.new_linearLayoutInner);
LL_Inner.setOrientation(LinearLayout.HORIZONTAL);
LL_Inner.setBackgroundColor(color.white);
LinearLayout.LayoutParams layoutForInner = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
LL_Inner.setLayoutParams(layoutForInner);
//LL_Outer.addView(LL_Inner);
ImageView IV = (ImageView) findViewById(R.id.new_imageViewPP);
//IV.getLayoutParams().height = 55;
//IV.getLayoutParams().width = 55;
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
params.setMargins(14, 12, 0, 0);
params.height = 55;
params.weight = 55;
IV.setBackgroundColor(color.black); …Run Code Online (Sandbox Code Playgroud) 一些常用的android布局,例如RelativeLayout和LinearLayout(当权重非零时)有onMeasure()实现,它们测量它们的子项两次,导致嵌套时的指数运行时间.这可以通过从叶子视图的onMeasure()中发出日志条目来轻松验证...它被称为2 ^深度时间.
有人可以给出明确和具体的描述,为什么这是?最重要的是,这种指数行为是由于整体合同的重要部分,还是只是一个可能被优化的实施细节?如果认为这是不可避免的,请举一个需要它的例子.
这样的例子将极大地帮助我和其他抱怨"保持你的布局浅"的任务是繁重的,并且想知道这是否仅仅是由核心库中尚未优化的算法驱动,或者是否确实存在阻止修复的根本困难.
也许最小的例子包括另一个LinearLayout内的LinearLayout内的Button(其中match_parent和weight = 1,触发完整的指数行为),以及一些额外的参数或情况,清楚地表明对Button的所有四个调用. onMeasure()确实有意义且必要.
我的第一个猜测是,实际上只需要两次线性时间遍历 - 第一次遍历以收集每个人的首选大小,第二次遍历来分配松弛和/或收缩.像Tex和Swing这样的世界上的其他布局引擎似乎能够经常处理具有大量对齐约束和延伸的非常深层次的层次结构,而没有任何指数爆炸,我想这就是它们的工作方式.
请注意,我不希望答案解释如何 发生指数性爆炸 - 我理解这一点,并且已经有几个帖子已经被问及并回答:
我的问题是递归双重测量是否从根本上是必要的/合理的,如果是,我想要一个明确的解释/示例来说明原因.
编辑2013/8/22:我想也许我的问题仍未解决.这次我会试着更大胆地澄清和解释我的动机.
布局不是一个指数级的难题,正如Tex和Swing等世界上有效的布局引擎所证明的那样.
那么,LinearLayout发生了什么,android开发者社区应该如何进行响应呢?我不是要本着责备的精神,而是要理解并决定如何最好地前进.
我可以想到4种可能性:
(4)对我个人来说不是一个严肃的选择.此外,我觉得在这一点上改变LinearLayout的行为是不切实际的,所以我不相信(2)也是一个严肃的选择.
离开(1)和(3).我有能力并愿意亲自去做其中任何一个,但哪一个?显然(1)如果可能的话,这是可取的 - 所以,有可能吗?这似乎是需要回答的关键阻塞问题,以确定如何向前发展.
我花了一些时间在核心代码和文档中并且它没有变得清晰,所以这就是为什么我在这里问这个问题.
我需要为不同的屏幕尺寸设备设置不同的布局权重,我想传递维度文件中的值,问题是来自维度文件的引用不断抛出错误
error: Error: Integer types not allowed (at 'progress_widget_item3_weight' with value '9').
Run Code Online (Sandbox Code Playgroud)
要么
error: Error: Float types not allowed (at 'progress_widget_item3_weight' with value '9.1').
Run Code Online (Sandbox Code Playgroud)
<dimen name="progress_widget_item3_weight">9</dimen>
Run Code Online (Sandbox Code Playgroud)
如何传递layout_weight的dimens文件中的值?谢谢
我想按百分比设置边距.我在线性布局中有4个图像视图,并希望设置默认的左,右,上,下边距,每个屏幕尺寸保持相同的百分比.
可能吗 ?
这是一个我想要的演示..

这就是我尝试过但不起作用的东西
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="10" >
<Thumbnail
android:id="@+id/thumb1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
<Thumbnail
android:id="@+id/thumb2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:weightSum="10" >
<Thumbnail
android:id="@+id/thumb3"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" >
</Thumbnail>
<Thumbnail
android:id="@+id/thumb4"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="4" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助
见附图.Twitter做得很好.他们有一个布局,我称之为工具栏,缺少一个更好的术语,就在屏幕键盘上方.我怎么能用我的代码做到这一点?

更新: 这是我的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff">
<RelativeLayout android:id="@+id/actionbarRelativeLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/actionbar_gradient">
<ImageButton android:id="@+id/imageButton" android:layout_width="wrap_content" android:background="@drawable/stocktwits" android:layout_height="wrap_content"></ImageButton>
<TextView android:layout_width="wrap_content" android:id="@+id/charCountTextView" android:text="140" android:layout_alignParentRight="true" android:layout_height="wrap_content" android:textColor="#ffffff" android:textStyle="bold" android:textSize="18sp" android:gravity="center_vertical" android:layout_centerVertical="true"></TextView>
</RelativeLayout>
<EditText android:layout_width="match_parent" android:id="@+id/composeEditText" android:focusable="true" android:hint="Share an idea with the community" android:gravity="left|top" android:layout_height="fill_parent" android:layout_weight="1"></EditText>
<LinearLayout android:layout_width="match_parent" android:id="@+id/border" android:background="#c4c4c4" android:baselineAligned="false" android:layout_height="1dp"></LinearLayout>
<LinearLayout android:layout_height="wrap_content" android:id="@+id/toolbarLinearLayout" android:orientation="horizontal" android:padding="5dip" android:layout_width="fill_parent" android:background="@drawable/gray_toolbar_gradient">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/shortenButton" android:background="@drawable/shortenbutton" android:layout_weight="0"></Button>
<LinearLayout android:layout_height="match_parent" android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:layout_weight="1"></LinearLayout>
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/twitterCheckBox" android:textColor="#000000" android:layout_weight="0" android:background="@drawable/twittergraybutton"></CheckBox>
<Button android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我正在开发小型Android应用程序,其中我将drawable资源设置为线性布局的背景.现在,我想要做的是动态地改变线性布局的背景颜色,但是在可绘制资源中.我的代码看起来像:
// bcd.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<gradient
android:endColor="#22000000"
android:startColor="#22000000"
android:angle="270" />
<stroke
android:width="3dp"
android:color="@color/white" />
<corners
android:radius="3dp" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
</shape>
</item>
Run Code Online (Sandbox Code Playgroud)
<LinearLayout
android:id="@+id/lin_llt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
Run Code Online (Sandbox Code Playgroud)
我在我的活动中设置了线性布局的背景,如下所示......
parentLayout = (LinearLayout) view.findViewById(R.id.lin_llt);
parentLayout.setBackgroundResource(R.drawable.bcd);
Run Code Online (Sandbox Code Playgroud)
现在我想做什么我想改变我的可绘制资源的颜色,这意味着改变我的线性布局的颜色,圆角和填充定义在drawable ..
我按照以下方式尝试了这个
ShapeDrawable bgShape = (ShapeDrawable )parentLayout.getBackground();
bgShape.getPaint().setColor(Color.BLACK);
Run Code Online (Sandbox Code Playgroud)
但它不适合我.任何其他解决方案
那怎么办......需要帮助......谢谢......
我想仰视图添加到Coordinator与布局view pager的话,底部视图将在顶部fragment的加载view pager和独立的吧.
我加了一个linear layout用
layout_gravity = "bottom"
Run Code Online (Sandbox Code Playgroud)
但底视图linear layout根本没有显示
以下是我的xml布局activity.
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/maintoolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="@+id/maintabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/mainviewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<LinearLayout
android:id="@+id/completeBottomView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBarBottomView"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="5dp"
android:indeterminate="false"
android:visibility="gone"
android:max="100"
android:progress="1"/>
<HorizontalScrollView
android:id="@+id/limiter_scroller"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:background="#FF3399"
>
<LinearLayout …Run Code Online (Sandbox Code Playgroud) android android-layout android-linearlayout android-coordinatorlayout