English 中文(简体)
在安内斯的弗拉梅莱乌特角进行现场观察
原标题:Place view inside FrameLayout in Android

我想从方案的角度补充一个观点,并将它置于具体 w和高的布局内。 Does 缺乏支持? 如果不是的话,我是否应该利用中间集团来实现这一目标?

int x; // Can be negative?
int y; // Can be negative?
int width;
int height;
View v = new View(context);
// v.setLayoutParams(?); // What do I put here?
frameLayout.addView(v);

我最初的想法是,在弗拉梅洛瓦特省增加“阿索尔特”一词,并把这一看法放在阿索尔特卢瓦底。 不幸的是,我刚刚发现,AbsoluteLayout被贬低。

任何要点都将受到高度赞赏。 感谢。

最佳回答

事实是,由于四分五裂,所有儿童都gged在屏幕上顶部,但你仍然对打小孩有某种控制。 如果你给不同儿童设定不同的婚礼价值,他们就会在弗拉梅乌特的不同地方展示。

问题回答

下面的例子(工作守则)表明,如何将观点(EditText)放在“框架”。 该表还显示,如何利用FilemeLayout的定点组确定EditText的位置(每当用户点击FolmeLayout时,EditText的位置被点击):

public class TextToolTestActivity extends Activity{
    FrameLayout frmLayout;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        frmLayout = (FrameLayout)findViewById(R.id.frameLayout1);
        frmLayout.setFocusable(true);
        EditText et = new EditText(this);

        frmLayout.addView(et,100,100);
        frmLayout.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                Log.i("TESTING","touch x,y == " + event.getX() + "," +     event.getY() );
                frmLayout.setPadding(Math.round(event.getX()),Math.round(event.getY()) , 0, 0);
            return true;
        iii
    iii);

iii

iii

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <FrameLayout 
        android:id="@+id/frameLayout1" 
        android:layout_height="fill_parent" android:layout_width="fill_parent">
    </FrameLayout>

</LinearLayout>

你们还可以在新增加的眼光上增加一个余地,以将其置于分裂状态。

FrameLayout frameLayout = (FrameLayout) findViewById(R.id.main); // or some other R.id.xxx
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(0, metrics.heightPixels - 20, 0, 0);
View v = new View(context);
v.setLayoutParams(params);
frameLayout.addView(v);

这将把20个雕像放在屏幕底层。

Edit: 填写了这个例子,因此它本身是存在的。 And oh, 是的。

http://developer.android.com/vis/android/widget/FrameLayout.html” rel=“nofollow” 1. Quinn1000提供:

你可以把多名儿童添加到支离破碎的地方,但所有儿童都关在屏幕上。

这就是说,你可以 put。 在FilemeLayout的某个特定地点(除非你希望位于左上角:-)。

如果你需要绝对定位,则尝试

允许你具体说明子女的确切地点(x/y坐标)。 绝对布局比没有绝对位置的其他类型布局更灵活,更难以维持。

关于确定观点的宽度和高度,如基松1000,你根据你选择的集装箱(AbsoluteLayout, LinearLayout,等)提供v.setLayoutParams(<>>>>>>>>>>> 方法





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签