【发布时间】:2014-07-24 00:48:55
【问题描述】:
我正在使用 AndroidSlidingUpPanel 库。 https://github.com/umano/AndroidSlidingUpPanel
我的 activity_main.xml 有两个孩子。第一个孩子是主要布局。第二个孩子是向上滑动面板的布局。 在这里,我发布了上滑面板的布局。 有 4 个 LinearLayout 定义为 15 : 15 : 60 : 10 % 的比例百分比。 第一个布局将在面板中可见。现在我希望面板高度是第一个布局的 3/4。所以在这里,第一个布局占屏幕的 15%,但面板高度应该在屏幕的 10-12% 左右。
有什么方法或公式可以用来获取屏幕尺寸并根据此处提供的 xml 文件的第一种布局设置面板高度。
我尝试在 Java 代码中定义面板高度。但直到现在还没有成功。 有时第二个布局也显示在面板中,有时只显示第一个布局的一半或 1/4。
PS:有什么方法可以在 setContentView() 之前找到视图的高度?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_weight="1.5"
android:background="#666666" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_weight="1.5"
android:background="#888888" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="6"
android:background="#eeeeee" >
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#202033" >
</LinearLayout>
【问题讨论】:
标签: java android xml android-layout layout