0
我想根據其他人的位置在我的視圖中放置元素。讓我來解釋:首先,我有兩個textviews,我已經成功地把第二(villeOffre)之一的,第一個(titreOffre):Android:如何設置TextViews位置取決於其他編程方式?
titreOffre = (TextView) findViewById(R.id.offreTitre);
titreOffre.setText(capitalizedString(offre.getTitle()));
villeOffre = (TextView) findViewById(R.id.offreVille);
villeOffre.setText(offre.getLocality());
infos = (TextView) findViewById(R.id.infos);
ViewTreeObserver vto = titreOffre.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener(
{
@Override
public void onGlobalLayout()
{
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) villeOffre.getLayoutParams();
params.setMargins(15,titreOffre.getBottom()+12,15,0);
villeOffre.setLayoutParams(params);
titreOffre.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
});
這工作完全,但現在我希望把第三的TextView (infos),這取決於villeOffre的位置。怎麼做 ?
非常感謝。
也許這會幫助你,如果不忘記接受它並投票給我。謝謝 :) – SALMAN 2012-07-16 16:34:41