标签: android-framelayout

FrameLayout和屏幕百分比

我有一个FrameLayout,它上面显示了一个LinearLayout我的意图是这个LinearLayout总是达到屏幕的33%...但我不能这样做.我尝试使用"dp",但当然,结果根据密度不同.如果他们是两个LinearLayout,如果我可以使用layout_weight =".33"和layout_weight =".67"但是FrameLayout在其中一个中使用.

我希望能够妥善解释

在此输入图像描述

提前致谢

问候

android percentage android-linearlayout android-framelayout

1
推荐指数
1
解决办法
4789
查看次数

如何以编程方式在FrameLayout中的另一个LinearLayout下添加LinearLayout?

FrameLayout frameLayout = new FrameLayout(this);
LinearLayout linearLayout1= new LinearLayout(this);
LinearLayout linearLayout2= new LinearLayout(this);

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

params.gravity = Gravity.CENTER_VERTICAL;

frameLayout.addView(linearLayout1, params);
Run Code Online (Sandbox Code Playgroud)

如何在linearLayout1下添加linearLayout2

android android-linearlayout android-framelayout

1
推荐指数
1
解决办法
1万
查看次数

android:如何在FrameLayout内的LinearLayout中添加填充

我有很多孩子的FrameLayout.其中一个孩子是LinearLayout.我想要LinearLayout的宽度,match_parent但大约90%左右; 这意味着我想添加某种paddingLeft/RightmargingLeft/Right.但是当我添加填充或边距时,它不会应用于图形布局.我该怎么做呢?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/blue" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:background="@color/red"
        android:marginLeft="20dp"
        android:marginRight="20dp"
        android:orientation="vertical" >
....
Run Code Online (Sandbox Code Playgroud)

android android-layout android-framelayout

1
推荐指数
1
解决办法
2万
查看次数

为什么 setVisibility 在 Fragment/FrameLayout 上不起作用

我有一个带有不确定进度条的布局,当超过 3 秒时,我想隐藏这个进度条并显示一个 web 视图,但由于某种原因它不起作用。

这是我的 XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/fl_register_oauth"
    tools:context=".fragments.RegisterFragment"
    android:background="@color/f_yellow">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity$PlaceholderFragment"
        android:gravity="center"
        android:layout_gravity="center"
        android:orientation="vertical">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/ll_pbar"
            android:gravity="center"
            android:visibility="gone">

        </LinearLayout>

        <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:indeterminateDrawable="@drawable/progress" />

        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/webView"
            android:visibility="gone"
            android:layout_gravity="center" />

    </LinearLayout>

    <FrameLayout
        android:id="@+id/FlashBarLayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|bottom"
        android:layout_marginBottom="72dp">
        <!-- flash bar content -->
    </FrameLayout>

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的片段源代码。

public class RegisterFragment extends Fragment {

...

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate …
Run Code Online (Sandbox Code Playgroud)

android visibility android-fragments android-framelayout

1
推荐指数
1
解决办法
2141
查看次数

Recyclerview:使第一个视图符号项从顶部开始一点空格

希望这张照片可以解释一下我想做什么.请记住,textview和recyclerview都是FRAMELAYOUT的ViewGroup.

在此输入图像描述

我想match_parentFRAMELAYOUT进行回收查看.该textview显示单词"邻居"必须在recyclerview的顶部.您无法从图像中看到它,但是它textview具有alpha0.5,因此它是半透明的.

我想要做的是让recyclerview viewholders你在图片中看到的深绿色项目,在高度下开始textview.这样,当用户滚动时recyclerview,项目将在半透明下正常滚动textview.

有没有办法确保recyclerview中的第一个项目从recyclerview的顶部(即textview的高度)稍微开始,以便可以实现这种效果?

android android-recyclerview android-framelayout

1
推荐指数
2
解决办法
3982
查看次数

如何动态设置android的FrameLayout的宽度和高度?

我试图设置2个框架布局的宽度和高度,这是2个片段的容器,它们都是线性布局的子代。

但是,每当我使用

frameLayout.setLayoutParams(new FrameLayout.LayoutParams(100,100);
Run Code Online (Sandbox Code Playgroud)

它导致类强制转换异常

java.lang.ClassCastException:android.widget.FrameLayout $ LayoutParams无法转换为android.widget.LinearLayout $ LayoutParams

android classcastexception android-linearlayout android-fragments android-framelayout

1
推荐指数
2
解决办法
1万
查看次数

在 FrameLayout 中动态添加多个片段

我正在尝试使用 FragmentTransaction 的 add() 方法将我正在创建的动态多个片段添加到框架布局中。每次我尝试这样做时,片段只是相互替换。

这是我的代码:

public class FragmentMerchandSearch extends Fragment {


    public FragmentMerchandSearch() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_merchand_search, container, false);
        FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
        for(int i = 0; i < 10; i++){
            Fragment newFragment = new FragmentMerchandPresentation();

            ft.add(R.id.container_merchand_presentation_for_search, newFragment);

        }
        ft.commit();

        return view;
    }
}
Run Code Online (Sandbox Code Playgroud)

这是 FragmentMerchandPresentation 的代码:

public class FragmentMerchandPresentation extends Fragment {

    public FragmentMerchandPresentation(){ …
Run Code Online (Sandbox Code Playgroud)

android dynamic android-layout android-fragments android-framelayout

1
推荐指数
1
解决办法
3763
查看次数

从错误的线程异常中调用

当我试图将另一个视图带到前面时,我在这里得到一个例外.它发生在我的BoardView类的最后一个方法中,它表示if(lives == 0).任何人都可以看到我应该在哪里调用这个来自?的方法?

public class BoardView extends SurfaceView implements SurfaceHolder.Callback{
Context mContext;

// thread initialization
private BoardThread thread;
Thread timer;

// box variables
Bitmap box = 
    (BitmapFactory.decodeResource
            (getResources(), R.drawable.box));
private int box_x = 140;
private int box_y = 378;
private int boxWidth = box.getWidth();
private int boxHeight = box.getHeight();

// storage
private Vector<Blossom> blossomVector = new Vector<Blossom>();
Iterator<Blossom> dataIterator = blossomVector.iterator();

// counters
private int blossomNum = 0;
private String score;
private int currentScore = 0;
private int lives = …
Run Code Online (Sandbox Code Playgroud)

android android-linearlayout android-edittext android-framelayout

0
推荐指数
1
解决办法
8357
查看次数

FrameLayout/WebView忽略对话框主题中的fill_parent

我有一个带有对话框主题的Activity.

<activity
    android:name=".MyActivity"
    android:theme="@android:style/Theme.Dialog" />
Run Code Online (Sandbox Code Playgroud)

该Activity使用以下xml布局:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/activity_article_frame_layout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000">
    <WebView
        android:id="@+id/activity_article_web_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />
    <Button
    android:id="@+id/activity_article_close_button"
        android:layout_width="25dip"
        android:layout_height="26dip"
        android:layout_marginTop="5dip"
        android:layout_marginRight="5dip"
        android:layout_gravity="right|top"
        android:background="@drawable/close_button" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

WebView的内容将从SD卡上的存储文件加载(作为意图数据提供的内容).这发生在onCreate()中:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_article);

    // Handle to the WebView
    mWebView = (WebView) findViewById(R.id.activity_article_web_view);
    initWebView();
    mWebView.loadDataWithBaseURL(null, myHtmlContent, "text/html", "utf-8", null);

    // Handle to the close button
    mCloseButton = (Button) findViewById(R.id.activity_article_close_button);
    mCloseButton.setOnClickListener(this);
}
Run Code Online (Sandbox Code Playgroud)

项目详情:minSDK:7(2.1)

我的问题是,WebView和/或FrameLayout没有fill_parent.活动的高度与按钮的高度完全相同.我几乎无法阅读我页面的第一行.我的问题只发生在蜂窝3.x上.在下面(<= 2.3),活动填充了父母,我看到了完整的网站.

我试图动态创建WebView.我试图在onCreate()中设置LayoutParams.没有改变.我也尝试在FrameLayout和WebView上调用invalidate(),但结果是一样的......

android webview invalidation fill-parent android-framelayout

0
推荐指数
1
解决办法
3448
查看次数

android:FrameLayout没有在底部放置布局

你好Android程序员,

我试图制作一个带有Framelayout的EditText和底部按钮栏的屏幕,这样无论用户编辑文本有多大,我的底部按钮栏都会保留在底部,因为FrameLayout使我的底部按钮栏位于顶部的屏幕.以下是我的代码.



    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
         >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" />

        <EditText android:id="@+id/tm_et_date_year" android:layout_width="120px" android:layout_height="wrap_content"/>

        <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/tm_ll_buttons" android:orientation="horizontal"
            android:gravity="bottom">
            <Button android:id="@+id/tm_btn_save" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Save" android:layout_weight="1" />
            <Button android:id="@+id/tm_btn_cancel" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Cancel" android:layout_weight="1" />
        </LinearLayout>
    </FrameLayout>

Run Code Online (Sandbox Code Playgroud)

然而,当我完成编码时,底部按钮栏突然出现在TOP而不是BOTTOM,如下所示.

http://img269.imageshack.us/img269/6374/71485552.jpg

我搜索了这个问题,但找不到任何可以帮助我的好文章,所以现在请教你.如果有人知道如何解决这个问题,你能帮助我吗?

谢谢阅读

android android-framelayout

0
推荐指数
1
解决办法
7546
查看次数

Listview行隐藏

我需要在framelayout中创建一个listview.

这是我的代码:

 <FrameLayout
            android:id="@+id/layout_ejercicios"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/layout_info"
            android:orientation="vertical">

            <ListView
                android:id="@+id/listViewEjercicios"
                android:layout_width="match_parent"
                android:layout_height="match_parent"></ListView>

            <include
                android:id="@+id/tool_bar_ejercicios"
                layout="@layout/toolbar" />

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fabCrearEntrenamiento"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom|end"
                android:layout_margin="16dp"
                android:clickable="true"
                android:src="@drawable/ic_action_add"
                app:fabSize="normal"
                app:layout_anchor="@id/layout_ejercicios"
                app:layout_anchorGravity="bottom|right|end" />
        </FrameLayout>
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但第一行总是被工具栏隐藏.其余的行看起来不错.

我尝试在row_layout.xml中添加padding_top,但不是解决方案.

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rowTextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:textSize="21sp" >
</TextView>
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

android listview android-framelayout

0
推荐指数
1
解决办法
82
查看次数

获取片段名称或 ID

我有framelayout一次在我Activity和其他时间的不同时间Fragment(经过相同framelayoutActivity)。

在 my 中MainActivity.class,我需要知道我的framelayout. 例如,我需要知道是否framelayout正在使用MyFragment1.classMyFragment2.class

我需要这样的东西(在这个例子中,log必须说我“你在 MyFragment1”):

FrameLayout frameLayout = (FrameLayout) findViewById(R.id.framelayout);

 getSupportFragmentManager().beginTransaction()
        .replace(R.id.framelayout,new MyFragment1())
        .commit();

if (framelayout.getname.equals("package.MyFragment1.class"))
 Log.d("debug", "you are in MyFragment1");
else if (framelayout.getname.equals("package.MyFragment2.class"))
 Log.d("debug", "you are in MyFragment2");
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

java android android-fragments android-framelayout

0
推荐指数
1
解决办法
2万
查看次数

无法使用“FrameLayout”,错误:“必须声明元素 FrameLayout”[Android Studio]

我正在 React Native 项目上进行少量 Android 开发,但我不知道如何“导入”FrameLayout。我确信这很简单,但经过一个小时的谷歌搜索后,我被难住了。

请参阅下面的错误:

谢谢,艾尔

android react-native android-framelayout

0
推荐指数
1
解决办法
959
查看次数