3
これは他の問題と似ていますが、私はそれがかなり独特な振る舞いをしていることを知っているので、誰かが説明することを願っていますWHYはこれです。ダブルクリックが発生するようにスクロールビューの最後の要素
基本的にはonClick
コードをトリガする前に二回クリックする必要のクリック可能な既知の問題です。
困ったことに、同じネストされたレイアウトの多くのインスタンスがONEの内部でしか起こらないということです。だから、
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imgBanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".80"
android:src="@drawable/banner" />
<ScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".20" >
<LinearLayout
android:id="@+id/panContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtMainTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="xxx" />
<TextView
android:id="@+id/txtMainSubtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="xxx" />
</LinearLayout>
</ScrollView>
</LinearLayout>
、バナー+タイトル+サブタイトルでスクロール:
は、私は、次の主要なレイアウトを持って
...見てみましょう。
だろう<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
<TextView
android:id="@+id/txtTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/txtSynopsis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/btnAction"
android:layout_below="@+id/txtTitle"
android:layout_toRightOf="@+id/imgCover" />
<ImageView
android:id="@+id/imgCover"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txtTitle" />
<Button
android:id="@+id/btnAction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imgCover"
android:layout_alignRight="@+id/imgCover"
android:layout_below="@+id/imgCover"
android:text="Download" />
<ImageView
android:id="@+id/imgFade"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/txtSynopsis"
android:layout_alignLeft="@+id/txtSynopsis"
android:layout_alignRight="@+id/txtSynopsis"
android:scaleType="fitXY"
android:src="@drawable/fade_down" />
<ImageView
android:id="@+id/imgMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imgFade"
android:layout_alignLeft="@+id/imgFade"
android:layout_alignRight="@+id/imgFade"
android:onClick="showMore"
android:src="@drawable/show_more" />
<ImageView
android:id="@+id/imgLess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/imgFade"
android:layout_alignRight="@+id/imgFade"
android:layout_below="@+id/txtSynopsis"
android:layout_marginTop="-12dip"
android:onClick="showLess"
android:src="@drawable/show_less"
android:visibility="gone" />
</RelativeLayout>
:左の
- タイトル:ブックの表紙+ダウンロードボタン私は、次のレイアウトでフォーマットされたいくつかのエントリを、挿入したい。このスクロールで
右側の - (その下):画像と、ダウンロードボタンの下にカット概要、それがバックグラウンド(imgFade)及び(プラスボタンを "「より多くを表示する」ボタンにフェージング見えるようにしますショーレシートAINS隠された)私は、
panContent
要素にこの方法を、いくつかのコンテンツを追加しているonCreate
方法で
:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LinearLayout panContent = (LinearLayout) findViewById(R.id.panContent);
for (EntryModel m : this.entries) {
ViewGroup g = new LinearLayout(this);
getLayoutInflater().inflate(R.layout.entry, g);
/* ... populating data in the TextView and ImageView ... */
panContent.addView(g);
}
}
ここで最後には、onClick
ハンドラは次のとおりです。
public void showMore(View v) {
RelativeLayout container = (RelativeLayout) v.getParent();
View txt = container.findViewById(R.id.txtSynopsis);
RelativeLayout.LayoutParams sLayout =
(RelativeLayout.LayoutParams) txt.getLayoutParams();
sLayout.addRule(RelativeLayout.ALIGN_BOTTOM, 0);
container.findViewById(R.id.imgFade).setVisibility(View.GONE);
container.findViewById(R.id.imgLess).setVisibility(View.VISIBLE);
v.setVisibility(View.GONE);
txt.setLayoutParams(sLayout);
}
public void showLess(View v) {
RelativeLayout container = (RelativeLayout) v.getParent();
View txt = container.findViewById(R.id.txtSynopsis);
RelativeLayout.LayoutParams sLayout =
(RelativeLayout.LayoutParams) txt.getLayoutParams();
sLayout.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.btnAction);
container.findViewById(R.id.imgFade).setVisibility(View.VISIBLE);
container.findViewById(R.id.imgMore).setVisibility(View.VISIBLE);
v.setVisibility(View.GONE);
txt.setLayoutParams(sLayout);
}
基本的には:
- WHE n "show more"画像をクリックし、
txtSynopsis
の下部をアンバインドして(画像が何列になるようにするか)、画像を非表示にして(フェードマスク)、 "show less"画像を表示します。 - 「表示しない」をクリックすると、よく復元されます。ここで行く
。これは完璧に(ほぼ...)すべてのシングルエントリーのために働いているが、最後の1つ!その1で何が起こる
は次のとおりです。
- 私は、「詳細を表示し、」上を2回クリックする必要があり、それが仕事持って、
- 私は「あまりを表示する」にTWICEクリックする必要が、それはだ
- "もっと見る"でONCEをクリックするだけでも十分ですが、
- "show less"でTWICEをクリックする必要があります。