Android的看到图像/当没看见方向改变 [英] Android Image is seen/not seen when orientation is changed
问题描述
我有一些问题,滚动型
和的ImageView
。
我要的是:
我有一个的ImageView
在屏幕顶部总是设置。然后,我有一个滚动型
去哪里了查看
中的所有元素,而且里面我有另一个 ImageView的
它被设定在当previous元件不填屏幕(通常大屏幕)的屏幕的底部,并且它被设置在<$ C $的底部C>滚动型时存在滚动。
I have an ImageView
set always at the top of the screen. Then, I have an ScrollView
where go all elements of the View
, and inside it I have another ImageView
which it is set at the bottom of the screen when previous elements don't fill screen (usually Big Screens), and it is set at the bottom of the ScrollView
when exists Scroll.
这是确定一些其他活动
我有,但我有一个活动的一些问题
具有的FrameLayout
。
It is ok for some other Activities
I have, but I have some problems in one Activity
that has a FrameLayout
.
我得到的是:
(见$ C $以下三)当我在 RelativeLayout的
的的ImageView
(一到集留在底部) HEIGHT =WRAP_CONTENT
:
(See code below) When I set in the RelativeLayout
of the ImageView
(the one to stay at the bottom) height = "wrap_content"
:
- 在纵向方向:将
图片
不用其真正的大小,因为它不适合在屏幕上。要适应它,滚动
应该会出现。 - >我不知道为什么它不会出现像在其他活动
。 - 在横向:
的ImageView
出现在屏幕的底部。至于其他元素不适合在屏幕上,滚动
出现在的FrameLayout
。
- In portrait orientation: The
Image
don't have its real size because it doesn't fit on the screen. To fit in it,Scroll
should appear. -> I don't know why it doesn't appear like in otherActivities
. - In landscape orientation:
ImageView
appears at the bottom of the screen. As other elements don't fit on the screen,Scroll
appears insideFrameLayout
.
当我在 RelativeLayout的
的的ImageView
(一个留在底部)<$ C的设置$ C> HEIGHT =200dp(图像的实际高度是小):
When I set in the RelativeLayout
of the ImageView
(the one to stay at the bottom) height = "200dp"
(real height of image is smaller):
- 在纵向方向:将
图片
不会出现。没有任何滚动
(因为其他因素被认为是没有必要的)。 - 在横向:出现两个
滚动
。一个在的FrameLayout
为元素,另一个用于看到的ImageView
。
- In portrait orientation: The
Image
doesn't appear. There isn't anyScroll
(it is not necessary because other elements are seen). - In landscape orientation: Appear two
Scrolls
. One insideFrameLayout
for elements, and another for seeing theImageView
.
这是我的code最新的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
tools:context=".FacturasActivity"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutLogoFactor_factura"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal" >
<ImageView
android:id="@+id/imageViewLogoFactor_factura"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo_factorenergia"/>
</LinearLayout>
<ScrollView
android:id="@+id/scrollViewMain"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/linearLayoutMain2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_gravity="center_horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayoutDireccionFactura"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="10dp"
android:weightSum="1.0">
<TextView
android:id="@+id/textViewlabelDireccionFactura"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:text="@string/etiqueta_direccion"
android:textSize="@dimen/textSize"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewDireccion"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:textSize="@dimen/textSize" />
</LinearLayout>
<FrameLayout
android:id="@+id/frameLayoutFacturas"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="10dp" >
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/facturas_vacia"
android:textSize="@dimen/textSize" />
</FrameLayout>
<RelativeLayout
android:id="@+id/linearLayoutImagenInferior_main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" >
<ImageView
android:id="@+id/imageViewImagenInferior_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:adjustViewBounds="true"
android:src="@drawable/la_electrica_de_las_empresas" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
你能帮助我吗?先谢谢了。
Can you help me? Thanks in advance.
推荐答案
该解决方案,我发现,在看<一个href=\"http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing\">that问题是:
The solution I've found, looking at that question, is:
创建功能:
public static void setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
// pre-condition
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
}
和我的ListView控件调用它。只有一个滚动
(一的滚动型
)被看到和使用。
and call it with my ListView. Only one Scroll
(the one of ScrollView
) is seen and used.
这篇关于Android的看到图像/当没看见方向改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!