1

私のアプリでは、フッターになるフラグメントのコンテナーとして次の FrameLayout を使用します。

<FrameLayout
android:id="@+id/frameLayoutFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true"/>

私のアクティビティでは、フラグメントを追加するために次のコードを使用します。

FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
mFooterFragment = new FooterFragment();
ft.add(R.id.frameLayoutFooter, mFooterFragment);
ft.commit();

私のフッターフラグメントのレイアウトは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footerContainer"
android:layout_width="fill_parent"
android:layout_height="165dip"
android:layout_alignParentBottom="true"
android:background="#15355b" >

<RelativeLayout
    android:id="@+id/relativeLayoutTopSetcion"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

..... some buttons and imageviews here...
</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayoutBottomSetcion"
    android:layout_width="fill_parent"
    android:layout_height="350dip"
    android:layout_alignParentBottom="true"
    android:visibility="**invisible**" >
..... some more imageviews and textviews here...
</RelativeLayout>
</RelativeLayout>

ある時点で、フッターを展開してイメージビューとテキストビューを追加したいと考えていますが、残念ながらすべての試行が失敗しました。その結果、フラグメントの FrameLayoutは展開されますが、その子は上部 (古い下部) の部分にとどまります。 alignParentBottom が true に設定されていても、フッターの高さが変化し、新しく追加された下部が透明になっているため、その子が新しいレイアウト パラメータで更新されていないと思います。 もう 1 つのことは、mRelativeLayoutBottomSetcion.setVisibility(View.VISIBLE) の変更が見られることですが、FrameLayout の下部 (新しく展開されたセクション) ではなく、展開前の元のサイズの下部にあります。

フラグメントを展開するために、この framents が属するアクティビティから次のコードを使用しました。

ViewGroup.LayoutParams params = mFrameLayoutFooter.getLayoutParams();
params.height = 500; 
mFrameLayoutFooter.requestLayout();
// setting the bootom relative layout to be visible
mRelativeLayoutBottomSetcion.setVisibility(View.VISIBLE);

私は何を間違っていますか?

消耗品フッターの既知の UI パターンはありますか?

前もって感謝します

4

3 に答える 3

0

最終的に、可視性がなくなったように設定されたRelativeLayoutを使用し、ここから取得したサイズ変更アニメーションを使用して展開しました。乾杯!

于 2012-10-24T19:57:28.300 に答える
0

わからないことがいくつかありますが、これであなたの質問に答えることができます。

まず、165dip しかない別の相対レイアウト内に 350dip の RelativeLayout (relativeLayoutBottomSetcion) があるのはなぜですか?

FrameLayout の高さを 165dip に設定し、RelativeLayout (footerContainer) の高さを fill_parent に設定する必要があると思います。これにより、高さを 500dip に変更した後でも、「footerContainer」を FrameLayout と同じ高さにすることができます。(そのとき、すでに行っているように、relativeLayoutBottomSetcion を VISIBLE にします)

また、可視性を INVISIBLE ではなく GONE に設定する必要があります。これは、INVISIBLE を使用すると RelativeLayout が画面上のスペースを占有するためですが、そのコンテンツは描画されません。

これを完了するには、android:layout_alignParentBottom="true" を削除します。これは、RelativeLayout の親が FrameLayout であり、この属性は親が RelativeLayout の場合にのみ機能するため、必要ないためです。

于 2012-07-17T17:05:14.367 に答える
0

あなたのコードに問題がある可能性があることに気付きました:

  1. フラグメントの親 RelativeLayout ( with @+id/footerContainer) には が固定されています。代わりにこれandroid:layout_height165dipに変更してください。match_parent

  2. を削除することもできandroid:layout_alignParentBottom="true"ます (親が FrameLayout であるため、とにかく機能しません - layout_alignParentBottomRelativeLayout の子でのみ機能します)。

  3. ポイント #1 の を に変更したので、必要165dipなものを取得するには、FrameLayout の を ( で) に変更する必要があります。match_parentandroid:layout_height="wrap_content"@+id/frameLayoutFooter165dip

于 2012-07-15T02:15:59.903 に答える