0
私はリニアレイアウトを持っています、そして、私は、もっと多くのアイテムを表示するためにgridview(hotelsGrid)を持っています、問題は私のアダプタを設定した後、グリッドビューを表示するには下に、私はトップに滞在する必要があります、どのように私はこれを達成することができますか?AndroidのGridviewはフォーカスを得ます
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/hotel_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ActivityHotelDetail">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="@color/colorPrimaryDark"
android:hapticFeedbackEnabled="true"
app:tabGravity="fill"
app:tabIndicatorColor="@color/colorPrimary"
app:tabIndicatorHeight="3dp"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<ScrollView
android:id="@+id/mainScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_vertical_margin"
android:background="@drawable/panel_with_border_nopadding"
android:orientation="vertical">
<TextView
android:id="@+id/hotelName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/fondo_titulo"
android:gravity="center"
android:paddingBottom="10sp"
android:text="Nombre del Hotel"
android:textAppearance="@android:style/TextAppearance.Large"
android:textColor="@color/textColorPrimary"
android:textSize="28sp"/>
<ImageView
android:id="@+id/hotelMainImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:paddingLeft="1dp"
android:paddingRight="1dp"
android:scaleType="fitCenter"
android:src="@drawable/fondo_360"/>
<LinearLayout
android:id="@+id/video360"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<com.google.vr.sdk.widgets.video.VrVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="250dip"
android:scrollbars="@null"/>
<ImageView
android:id="@+id/playButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="10dip"
android:adjustViewBounds="true"
android:background="@drawable/playbutton"
android:scaleType="fitXY"/>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:id="@+id/play_toggle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:paddingStart="0dp"
android:paddingTop="4dp"
android:src="@drawable/play_on"/>
<!-- Seeking UI & progress indicator.-->
<SeekBar
android:id="@+id/seek_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_weight="8"/>
<ImageButton
android:id="@+id/volume_toggle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:paddingStart="0dp"
android:paddingTop="4dp"
android:src="@drawable/volume_on"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/hotelDistance"
android:layout_width="match_parent"
android:layout_height="26sp"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="1dp"
android:layout_marginRight="1dp"
android:background="@drawable/fondo_distancia"
android:gravity="center"
android:text="distance"
android:textColor="@color/textColorPrimary"/>
<TextView
android:id="@+id/hotelAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/imagepreview"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:gravity="center"
android:text="Direccion"
android:textColor="@color/textColorSecundary"/>
<TextView
android:id="@+id/hotelDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:gravity="center"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:text="Descripcion"/>
</LinearLayout>
<RelativeLayout
android:id="@+id/otherHotelsRL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:layout_marginTop="20dp"
android:background="@drawable/panel_with_border_nopadding"
android:paddingLeft="1dp"
android:paddingRight="1dp">
<TextView
android:id="@+id/otherViewsTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="Fotos"
android:textColor="@color/textColorSecundary"
android:textSize="22sp"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/otherViewsTxt"
android:layout_marginBottom="10dp"
android:fillViewport="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/thumb1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:src="@mipmap/icon_360"/>
<ImageView
android:id="@+id/thumb2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/thumb1"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:src="@mipmap/icon_360"/>
<ImageView
android:id="@+id/thumb3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/thumb2"
android:layout_weight="1"
android:src="@mipmap/icon_360"/>
</LinearLayout>
</HorizontalScrollView>
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:alpha="0.8"
android:background="#222222"
app:srcCompat="@drawable/ic_chevron_left_white_24dp"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:alpha="0.8"
android:background="#222222"
app:srcCompat="@drawable/ic_chevron_right_white_24dp"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="30dp"
android:layout_marginLeft="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_vertical_margin"
android:layout_marginTop="20dp"
android:orientation="vertical"
android:paddingBottom="1dp"
android:paddingLeft="1dp"
android:paddingRight="1dp">
<TextView
android:id="@+id/otherHotelsTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@drawable/panel_with_border_padding"
android:gravity="center"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="Mas Hoteles Interesantes"
android:textColor="@color/textColorSecundary"
android:textSize="22sp"/>
<GridView
android:id="@+id/hotelsGrid"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:horizontalSpacing="15dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="15dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
を設定した後、フォーカス可能な追加:真とfocusableintouch:トップレイアウトに忠実に。 。。ともタグ –
いや...それは(view.requestFocus()){ getActivity()場合 – Chico3001
ます。private voidのrequestFocus(ビュービュー){ を働いていたdidntのは、GetWindow()setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)を置きます。 } } –