求教关于聊天界面开发中出现的问题

本人是刚入门不久的新手,熟悉的东西不是特别多,今天在弄一个聊天界面时出现下面三个问题:
(1)就是当发送的信息文字比较多时会把头像给挤掉,不知道有什么办法处理这种问题
(2)怎么样能在各种情况下都能保证文字信息在背景图中始终保持竖直和水平方向的居中位置,因为.9.png格式的背景图片根据文字长度被拉长后总是会有一些情况下是不能居中的
其实上面两个问题也可以说是我们平常用的微信和qq这种聊天界面是怎么样处理我上面所描述的问题
(3)还有就是那个bottom navigationbar能不能在EditText获得焦点的时候隐藏,就是我们要输入信息的时候,下面那个bottom navigabar能不能隐藏,不然感觉很奇怪。因为下面那个bottom navigationbar我是引入github项目的,那个导航栏的源码比较多,我也不知道放出哪个,所以我就放出那个github项目的地址: https://github.com/Ashok-Varma/BottomNavigation


使用listview构建聊天界面,包含三个相关文件msg_item.xml、Msg.java、MsgAdapter.java,与界面布置有关的就是xml文件,所以我只放出了xml文件的代码,我也不清楚是不是java代码也能解决这个问题,还是只有通过xml属性来解决,github项目我是作为library引进自己的项目,这样java代码特别多,所以我就放出一些关键的代码,如果有哪位好心的大神有办法解决这个问题的,我想亲自加你qq求教。

msg_item.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:background="#EBEBEB">

    <LinearLayout
        android:id="@+id/left_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        >

        <ImageView
            android:id="@+id/left_msg_imageView"
            android:layout_width="30dp"
            android:layout_height="match_parent"
            android:src="@drawable/g1"/>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/message_left">

            <TextView
                android:id="@+id/left_msg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="6dp"
                android:textColor="#505050"/>
        </LinearLayout>


    </LinearLayout>

    <LinearLayout
        android:id="@+id/right_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/message_right">

            <TextView
                android:id="@+id/right_msg"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="2dp"
                android:textColor="#505050"/>
        </LinearLayout>

        <ImageView
            android:id="@+id/right_msg_imageView"
            android:layout_width="30dp"
            android:layout_height="match_parent"
            android:src="@drawable/g2"
            />
    </LinearLayout>

</LinearLayout>


MainActivity.java
package com.example.wangchang.testbottomnavigationbar;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.ashokvarma.bottomnavigation.BottomNavigationBar;
import com.ashokvarma.bottomnavigation.BottomNavigationItem;
import java.util.ArrayList;


public class MainActivity extends AppCompatActivity implements BottomNavigationBar.OnTabSelectedListener {
    private ArrayList<Fragment> fragments;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
        bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
        bottomNavigationBar
                .setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
        bottomNavigationBar.addItem(new BottomNavigationItem(R.mipmap.ic_home_white_24dp, "首页").setActiveColorResource(R.color.orange))
                .addItem(new BottomNavigationItem(R.mipmap.ic_music_note_white_24dp, "活动").setActiveColorResource(R.color.blue))
                .addItem(new BottomNavigationItem(R.mipmap.ic_book_white_24dp, "咨询").setActiveColorResource(R.color.teal))
                .addItem(new BottomNavigationItem(R.mipmap.ic_tv_white_24dp, "我").setActiveColorResource(R.color.brown))
                .setFirstSelectedPosition(0)
                .initialise();

        fragments = getFragments();
        setDefaultFragment();
        bottomNavigationBar.setTabSelectedListener(this);
    }

    /**
     * 设置默认的
     */
    private void setDefaultFragment() {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction transaction = fm.beginTransaction();
        transaction.replace(R.id.layFrame, RecommendationFragment.newInstance("首页"));
        transaction.commit();
    }

    private ArrayList<Fragment> getFragments() {
        ArrayList<Fragment> fragments = new ArrayList<>();
        fragments.add(RecommendationFragment.newInstance("首页"));
        fragments.add(ActivityFragment.newInstance("活动"));
        fragments.add(ConsultFragment.newInstance("咨询"));
        fragments.add(AboutFragment.newInstance("我"));
        return fragments;
    }

    @Override
    public void onTabSelected(int position) {
        if (fragments != null) {
            if (position < fragments.size()) {
                FragmentManager fm = getSupportFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                Fragment fragment = fragments.get(position);
                if (fragment.isAdded()) {
                    ft.add(R.id.layFrame, fragment);
                } else {
                    ft.replace(R.id.layFrame, fragment);
                }
                ft.commitAllowingStateLoss();
            }
        }

    }

    @Override
    public void onTabUnselected(int position) {
        if (fragments != null) {
            if (position < fragments.size()) {
                FragmentManager fm = getSupportFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                Fragment fragment = fragments.get(position);
                ft.remove(fragment);
                ft.commitAllowingStateLoss();
            }
        }
    }

    @Override
    public void onTabReselected(int position) {
    }

}


这是出现问题的界面情况



这是项目结构图


我向各位大神真心求教,谢谢!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PHP常用的加密方式有很多,比如MD5、SHA1、base64等。但它们都不支持文加密,因为它们只针对ASCII码进行加密。要支持文加密,我们需要使用其他加密方式,比如mcrypt或openssl。 下面是一个使用openssl加密解密文的例子: ```php // 加密函数 function encrypt($str, $key) { $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-128-cbc')); $encrypted = openssl_encrypt($str, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv); return base64_encode($iv . $encrypted); } // 解密函数 function decrypt($str, $key) { $data = base64_decode($str); $iv = substr($data, 0, openssl_cipher_iv_length('aes-128-cbc')); $encrypted = substr($data, openssl_cipher_iv_length('aes-128-cbc')); return openssl_decrypt($encrypted, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv); } // 测试 $str = '这是一段文字符串'; $key = '1234567890abcdef'; $encrypted = encrypt($str, $key); echo $encrypted . "\n"; $decrypted = decrypt($encrypted, $key); echo $decrypted . "\n"; ``` 输出结果如下: ``` oGx3/4OJZwM2kK1z3nIKP0qkZ/jxjyX7pBt0g3wqE9E= 这是一段文字符串 ``` 上述代码,我们使用了AES-128-CBC加密方式,这是一种对称加密方式,需要提供一个密钥,加密和解密都用同一个密钥。在加密,我们随机生成一个iv向量,将iv和加密后的数据一起base64编码返回。在解密,我们从base64解码得到iv和加密后的数据,然后使用相同的密钥和iv进行解密。 注意,上述代码使用了openssl_random_pseudo_bytes函数生成iv向量,这是一个伪随机数生成函数,安全性较高。如果你使用的PHP版本不支持该函数,可以考虑使用其他随机数生成函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值