首页 \ 问答 \ 为什么不出现FloatingActionButton?(Why does not appear FloatingActionButton?)

为什么不出现FloatingActionButton?(Why does not appear FloatingActionButton?)

我将我的问题改为更易于理解的问题。 但现在又出现了另一个问题。 为什么不出现FloatingActionButton

为什么不出现FloatingActionButton为什么不出现FloatingActionButton


public class Home extends MyAppCompact 
{
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home); //This is problem
    }

}

//

public class MyAppCompact extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout.LayoutParams layoutParams=new LinearLayout.
                LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        FloatingActionButton floatingActionButton=new FloatingActionButton(this);
        layoutParams.gravity= Gravity.BOTTOM|Gravity.RIGHT;
        layoutParams.setMargins(16,16,16,16);

        floatingActionButton.setLayoutParams(layoutParams);
        floatingActionButton.setImageResource(R.drawable.ic_mic_white_24dp);
        floatingActionButton.setClickable(true);

        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                Bitmap bitmap=getScreenShot();
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                byte[] byteArray = stream.toByteArray();

                Intent intent = new Intent(MyAppCompact.this, FeedBack.class);
                intent.putExtra("bitmapData", byteArray);
                startActivity(intent);
            }
        });

        LinearLayout.LayoutParams layoutParams1=new LinearLayout.
                LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
        );

        addContentView(floatingActionButton,layoutParams1);

        //
//            <android.support.design.widget.FloatingActionButton
//        android:layout_width="wrap_content"
//        android:layout_height="wrap_content"
//        android:layout_gravity="bottom|right"
//        android:layout_margin="16dp"
//        android:id="@+id/btnFloating"
//        android:clickable="true"
//        android:src="@drawable/ic_mic_white_24dp" />
    }

    public Bitmap getScreenShot() {
        View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
        View screenView = rootView.getRootView();
        screenView.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
        screenView.setDrawingCacheEnabled(false);
        return bitmap;
    }
}

I changed my question to a more understandable one. But now there was another problem. Why does not appear FloatingActionButton

Why does not appear FloatingActionButton Why does not appear FloatingActionButton


public class Home extends MyAppCompact 
{
   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home); //This is problem
    }

}

//

public class MyAppCompact extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout.LayoutParams layoutParams=new LinearLayout.
                LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        FloatingActionButton floatingActionButton=new FloatingActionButton(this);
        layoutParams.gravity= Gravity.BOTTOM|Gravity.RIGHT;
        layoutParams.setMargins(16,16,16,16);

        floatingActionButton.setLayoutParams(layoutParams);
        floatingActionButton.setImageResource(R.drawable.ic_mic_white_24dp);
        floatingActionButton.setClickable(true);

        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                Bitmap bitmap=getScreenShot();
                bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
                byte[] byteArray = stream.toByteArray();

                Intent intent = new Intent(MyAppCompact.this, FeedBack.class);
                intent.putExtra("bitmapData", byteArray);
                startActivity(intent);
            }
        });

        LinearLayout.LayoutParams layoutParams1=new LinearLayout.
                LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
        );

        addContentView(floatingActionButton,layoutParams1);

        //
//            <android.support.design.widget.FloatingActionButton
//        android:layout_width="wrap_content"
//        android:layout_height="wrap_content"
//        android:layout_gravity="bottom|right"
//        android:layout_margin="16dp"
//        android:id="@+id/btnFloating"
//        android:clickable="true"
//        android:src="@drawable/ic_mic_white_24dp" />
    }

    public Bitmap getScreenShot() {
        View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
        View screenView = rootView.getRootView();
        screenView.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(screenView.getDrawingCache());
        screenView.setDrawingCacheEnabled(false);
        return bitmap;
    }
}

原文:https://stackoverflow.com/questions/43013819
更新时间:2022-06-26 20:06

最满意答案

我能想到的唯一的事情就是使用CDN角色,图像上可能会有更好的标题(Cache-Control,Expires),以便浏览器和代理可以长时间缓存这些图像,而如果您提供这些图像从您的主站点开始,您负责控制这些资源上的标题。

提供来自不同域的图像也将有所帮助,因为托管在CDN上的所有资源请求(不同域名,不使用第三级域名)不会包含主站点所需的cookie和身份验证标头。


The only thing I can think of is that using a CDN role, you might have better headers on images (Cache-Control, Expires), so that the browser and proxies can cache for a long time those images, while if you serve those images from your main site you're in charge of controlling the headers on those resources.

Serving images from a different domain will also help, because all the request to resources hosted on the CDN (different domain name, do not use 3rd level domains) will not contain the cookies and authentication headers you need for the main site.

相关问答

更多
  • 最后,我选择了第二个选项。在我看来,在完成HTML页面投放前,通过“过滤”URL来实质模拟CMS。 正则表达式,BeautifulSoup或其他的URL替换 每个URL被替换如下: -> " /> 这也将起作用: ->
  • CDN的价值在于用户已经访问了从该CDN呼叫相同文件的另一站点的可能性,并且根据文件的大小变得越来越有价值。 这种情况的可能性随着被请求文件的普及和CDN的普及而增加。 考虑到这一点,从流行的CDN拉一个相对较大和流行的文件是绝对意义上的。 jQuery,而在较小程度上,jQuery UI适合这个帐单。 同时,连接文件对于不太可能发生变化的较小文件是有意义的 - 您常用的插件将适合此法案,但您的核心应用程序特定代码可能不会:它可能会每周更改,将其与所有其他文件连接起来,您必须强制用户再次下载所有内容。 HT ...
  • 你是对的。 对于PhoneGap的新手而言,这是一个常见的错误,导致应用程序启动缓慢。 根据这种情况,使用移动PhoneGap应用的CDN实际上可能是一种弊端。 由于web浏览器/浏览器的行为,PhoneGap对所有资源都是本地挑剔。 如果你想让你的应用程序加载速度快,所有你的初始资源应该是本地的。 如果你是一个web开发者,你可能会遇到建议将JS文件加载到body标签的末尾,而不是在head标签中。 Webview /浏览器线程可用性与PhoneGap中的文件本地更好相同。 请记住,在PhoneGap设备 ...
  • 我能想到的唯一的事情就是使用CDN角色,图像上可能会有更好的标题(Cache-Control,Expires),以便浏览器和代理可以长时间缓存这些图像,而如果您提供这些图像从您的主站点开始,您负责控制这些资源上的标题。 提供来自不同域的图像也将有所帮助,因为托管在CDN上的所有资源请求(不同域名,不使用第三级域名)不会包含主站点所需的cookie和身份验证标头。 The only thing I can think of is that using a CDN role, you might have be ...
  • 创建一个名为custom.css的新文件,并在CDN版本之后将其包含在 。
    我发现的最佳解决方案是将版本标记更改为url的开头,并使用url rewrite来处理请求。 因此,如果我曾经有过: http://website/Content/Images/1.png?123456 这将成为: http://website/123456/Content/Images/1.png 请注意,我使用url rewrite按顺序处理请求,以便http://website/123456/Content/Images/1.png实际上将从http://website/Content/Image ...
  • 浏览器在给定时间发送到域名的请求数量有限制。 现在,限制是对桌面浏览器的6-10个请求。 在IE6时,这个限制是2。 此限制也适用于移动浏览器。 那么,如果您的网站有很多内容需要并行下载(图片?),那么使用2个CDN并拥有不同的主机名是有意义的。 There is a limit on the number of requests the browser will send to a domain name at a given time. Right now the limit is 6-10 reque ...
  • 我使用以下步骤在Spring中实现了CDN服务: 在dispatcher-servlet.xml添加以下行(您的Spring配置) 当然,您需要在文件顶部为spring-util添加DOM: xmlns:util ...
  • 只有位于项目根目录下的文件用于完成/导航/错误突出显示,WebStorm不会使用网上资源进行类型解析。 所以你必须下载css并使用相对URL来引用它来完成工作 Only files located under your project root are used for completion/navigation/error highlighting, WebStorm doesn't use online resourses for types resolving. So you have to down ...
  • 鉴于您的https链接现在都在运行,您看到的问题仅仅是由于SSL配置传播的延迟。 Azure CDN的所有配置更改最多可能需要60分钟才能传播到所有CDN POP(即CDN数据中心)。 CDN配置是唯一与其关联的延迟项。 当客户端请求内容时,内容会自动缓存到单个POP。 如果客户端未对您的内容发出任何请求,则不会在CDN POP上缓存任何内容。 Given that your https links are all now working the issue you saw would have been ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)