首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >利润率,手机和平板电脑,多个片段,android

利润率,手机和平板电脑,多个片段,android
EN

Stack Overflow用户
提问于 2013-05-11 17:09:19
回答 1查看 386关注 0票数 0

我正在为手机和平板设备设计一个应用程序。当我在XML-layout中使用权重属性时,平板电脑上的间距并不是理想的效果,因为它们在平板电脑上伸展得太远了。

举个例子-在电话里它看起来像这样

-5DP-框架1

-5DP-框架2

-5DP-(-T1-)(--T2-)-5DP-

所以它很漂亮,看起来很干净,t1的weight值为1,t2的weight值为2。

---Frag1---|-------------------------------Frag3

---Frag2---|-(Text1---------)------------(-----Text2------------------------)-

现在我知道这是因为它的T1 = weight 1占屏幕的33%,T2 = weight 2占屏幕的66%。我的问题:有没有办法让两个元素中心,或者把这两个元素推到一起,这样它们看起来就不会有很大的空隙?他们是这样的吗?

---Frag1---|-------------------------------Frag3

---Frag2---|--------(Text1---------)-(-----Text2--------------------)

我尝试在我的layout-margins中为左和右设置XML,但是它什么也没做。

我不介意为平板电脑做一个完全不同的布局,但是这个东西会有大量的fragments (50-100),每个单打都会非常耗时,而且会让人非常头疼。如果我能对fragment容器做些什么来以我想要的方式操作外观,我会很高兴的。如设置页边距等。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-11 20:06:07

我最终要做的是修复这个问题,给碎片容器赋予权重值。最终的结果是,左边的碎片伸展了一点,使右边的碎片进行了调整。

这是代码

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/MainLayout"
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="horizontal" >

<LinearLayout 
    android:id="@+id/container"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:orientation="vertical">

<LinearLayout
    android:id="@+id/store_fragment_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
</LinearLayout>

<LinearLayout
    android:id="@+id/header_fragment_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:scrollbars="vertical" >
</LinearLayout>

</LinearLayout>

<LinearLayout
    android:id="@+id/content_fragment_container"
    android:layout_width="0dp"
    android:layout_height="wrap_content"        
    android:layout_weight="2"
    android:orientation="vertical"
    android:scrollbars="vertical" >
</LinearLayout>

</LinearLayout>

最终结果是这样的,屏幕上的比例为33%/66%。

-框架1

-框架2

不完全是我想要的,但效果相对不错。如果其他人有更好的解决方案,我会接受的。谢谢!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16499673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档